I am trying to switch to CustomTabs from WebViews as it has been disabled by Facebook for login. For this, I need to get the access token from the URL in the custom tab. How can I do this without requiring the user to click somewhere?
Asked
Active
Viewed 1,223 times
0
-
I didn't know Facebook had disabled WebViews. Do you have a link for an announcement? Or, do you know when this change happened? – andreban Oct 19 '21 at 15:34
-
Yes, https://developers.facebook.com/docs/facebook-login/android/deprecating-webviews – UchihaItachi Oct 19 '21 at 18:02
1 Answers
0
The Facebook login SDK already uses Custom Tabs under the hood. There are docs on how to use it in your application here: https://developers.facebook.com/docs/facebook-login/android/
In order to implement this manually, you need to create an Activity that has intent-filter that uses a custom schema and use that schema as the redirect URL for the OAuth flow. There's a sample that implements this flow for the GitHub OAuth here https://github.com/GoogleChrome/android-browser-helper/tree/main/demos/custom-tabs-oauth.

andreban
- 4,621
- 1
- 20
- 49
-
But Facebook only allows URIs with the HTTPS scheme to be used as valid OAuth redirect URIs. – UchihaItachi Oct 20 '21 at 03:29
-
Their docs point out to the following as the protocol scheme:
fb649326238470013 . Is it the case you can't change this on their configuration UI? – andreban Oct 20 '21 at 14:43 -
Additionally, it's possible to implement this with an HTTPs scheme, as long as you implement Digital Asset Links for the origin (the demo on GitHub actually uses HTTPs https://github.com/GoogleChrome/android-browser-helper/blob/main/demos/custom-tabs-oauth/src/main/AndroidManifest.xml) – andreban Oct 20 '21 at 14:46