Hello :wave: At the moment, I’m working on a webvi...
# android
r
Hello 👋 At the moment, I’m working on a webview and I’m trying to put a token header. However, during any redirection, this token no longer appears. During the first call, the token is present in the header but when I enter the functions shouldOverrideUrlLoading and shouldInterceptRequest the header is empty. An idea of how to do this? I already try several solutions on the net, including the one to add the header by hand using okhttp when calling shouldInterceptRequest but nothing ...
google 2
stackoverflow 3
p
Are you using Android CookieManager? I had an issue like that using the Android Cookie Manager with Chrome version 71. But it got fixed in 72.
Headers are saved by url, if the redirection points to a different url they are not kept.
r
When there is a redirect in the webview, cookies are not kept?
p
I remember back in time from a WebView login integration I did for a company,I had a similar problem. My headers were empty in all the WebView Callback events. Reasons can be multiple. Now, regarding your question. Headers are not handled by the system, the system only handle a couple of basic headers like
userAgent
. You have to send the headers manually when you call the load() method. The only type of headers the system handles for you is the Cookies. If you use the CookieManager you can inject your Cookies there and it will take care of the rest. The benefits is that the same CookieManager is a Singleton used by Chrome App too. So you can re-use Cookies-Login Tokens between your app and Chrome seamlessly. Cookies are saved by url hostname. If the redirect url has a different hostname, then the original request Cookies are not sent. With the rest of the header types am not sure whats the behavior but is probably the same as the cookies. Maybe for security reasons they do not transfer the original Url headers to the redirected Url. In such a case you would have to do it on your own.