0

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?

1 Answers1

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