Issue
So I'm setting up a WebView to show a partners website. If the user does not have the feature set up. it will redirect them to our website, since they are logged in on the device I need to pass our Authentication token in the request headers and our website will automatically log them.
It works on iOs but I can't get it to work on Android. I'm intercepting the redirect and if it is to our website I am adding the auth header. But it is not logging the user into the site. It just shows our login page. The code is bellow.
webView?.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
if(!url!!.contains("ourwebsite.com/authenticate"))
return false
val am: AccountManager = AccountManager.get(context)
val token = am.getPassword(Application.getAccount())
val extraHeaders: MutableMap<String, String> = mutableMapOf()
extraHeaders.put(AUTH_KEY, token)
view?.loadUrl(url, extraHeaders)
return false
}
Solution
So our server folks were kind enough to add some logs for me and I saw this in the recorded headers
"auth-header": "some token",
When I'm adding the auth header in I'm adding with capitalization (because that is what is required by the server:
"Auth-Header"
Apparently the rom RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", Section 4.2, "Message Headers": states that headers are not case sensitive. :(
So our servers need to handle the all lowercase protocol.
Answered By - Dan Anderson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.