Search code examples
androidreact-nativeoauth-2.0intentfilter

Open Android app when browser redirects for OAuth2


I am creating an app with react-native, and basically we're handling OAuth2 to google, fb and linkedIn with our backend. The flow would be:

  1. Mobile app (click on Sign in with Facebook) which is just a link to our backend like backend.com/oauth/facebook
  2. Backend will redirect to facebook OAuth login
  3. After authorizing there will be another redirect to backend
  4. Finally it will redirect to our website with the token

The point is that I have intent-filter

    <intent-filter android:label="myApp">
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />

      <data android:scheme="http" />
      <data android:scheme="https" />
      <data android:scheme="myWebsite" />
      <data android:host="*.myWebsite.com" />
      <data android:host="myWebsite.com" />
    </intent-filter>

However this works only for link clicks, not for browsing or redirecting. Is there any way to make this work with redirects too, or that's impossible and I'll have to find another way to handle mobile app's OAuth?


Solution

  • Okay, so the answer will be about universal links. This should probably work on both iOS and Android, however it needs to set up some files on server side.

    However this is working only on Chrome browser.