GoogleChrome / android-browser-helper

The Android Browser Helper library helps developers use Custom Tabs and Trusted Web Activities on top of the AndroidX browser support library.
Apache License 2.0
688 stars 286 forks source link

Authorisation Issue in Header #364

Open rahul-kumawat-vts opened 2 years ago

rahul-kumawat-vts commented 2 years ago

Hi,

We've integrated browser Android SDK in our Production app and currently, we're on version v1.3.0 (androidx.browser:browser:1.3.0). We've encountered an issue with the SDK. Whenever we are trying to access the URL by passing the Authorization token as a header, we are not able to open the URL. The same thing is working whenever we are trying to open in the web chrome browser. So the expectation is if the user is already using the shared session(The user is already Registered on it). It should not ask the user to enter the credentials again. Please find the attached code for your reference The user should be auto-login when we pass the authorization token in the header. The user should be redirected to the webpage without getting a login page.

We've inspected the Chrome custom tab with the help of chrome://inspect/#devices, and the passed header parameter is not visible in the request when we check in the inspect.

Below is the code we're using to open a web URL inside the chrome custom tab:

val customTabsIntent = CustomTabsIntent.Builder().build()
customTabsIntent?.intent?.setPackage("com.android.chrome")     
val headers = Bundle()
headers.putString("Authorization", "Bearer $authToken") //authToken contain the Authorization token value.

customTabsIntent?.intent?.putExtra(Browser.EXTRA_HEADERS, headers)

context?.let { nonNullContext ->                          
customTabsIntent?.launchUrl(nonNullContext,Uri.parse(webViewUrl) //webViewUrl contain the string value of URL which we need to open in web page.
}

Please let me know if there is anything else I need to add to make it work. Thanks

ujjwal1990 commented 1 year ago

@rahul-kumawat-vts did you find any solution for this? I tried the Digital Asset Link approach as well described here