proyecto26 / react-native-inappbrowser

📱InAppBrowser for React Native (Android & iOS) 🤘
https://www.npmjs.com/package/react-native-inappbrowser-reborn
MIT License
1.29k stars 220 forks source link

open/openAuth won't redirect to the app with Dynamic Link #389

Open namluu25 opened 1 year ago

namluu25 commented 1 year ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

The flow i'm working on:

User click on Integrate with Instagram > InAppBrowser opens Instagram OAuth link to grant access > Redirect to Redirect URI set on Facebook Developer (Dynamic link) > Dynamic link redirect back to app with the specific screen

I've tried both open() and openAuth(), both stopped at the Redirect to Dynamic link step and won't let Dynamic link navigate to the app (and close the In App Browser view). When i tried on Chrome/Safari itself it redirected just fine.

Sample code

export const signInInstagram = async () => {
  const url = `https://api.instagram.com/oauth/authorize?client_id=${config.INSTAGRAM_APP_ID}&redirect_uri=${config.INSTAGRAM_REDIRECT_URL}&scope=user_profile,user_media&response_type=code`;
  try {
    if (await InAppBrowser.isAvailable()) {
      InAppBrowser.open(url, {
        // iOS Properties
        ephemeralWebSession: false,
        // Android Properties
        showTitle: false,
        enableUrlBarHiding: true,
        enableDefaultShare: false,
      });
    } else Linking.openURL(url);
  } catch (error) {
    Logger.debug('instagram error: ', error);
  }
};

The ${config.INSTAGRAM_REDIRECT_URL} has a type like: https://abc.com/def. When user triggers that link, it redirect to myapp://def

esbenvb commented 1 year ago

I have the same issue. I'm using openAuth to open a session which is making an appswitch to MitID, which handles the login and makes a switchback by calling a universal link to the app.

However, when the app is called again, the link is handled by the inapp-browser which shows a 404 error. I was expecting the in app browser to "catch" this redirect backswitch and close the browser and resolve the promise with the redirect link...

The callback redirect URL is https://bosjapp.bosj.dk/login/oidc?code=05a.................b51&state=initial

I'm calling the browser like this:

const result = await InAppBrowser.openAuth(
        url,
        'https://bosjapp.bosj.dk/login/oidc',
        options
      )

But here is what I get. image

If I click the same URL somewhere else on the iphone, it will go to the app and the URL will be processed by the app. But not when the in-app-browser is open...

MayoudP commented 1 year ago

I have the same issue. I'm using openAuth to open a session which is making an appswitch to MitID, which handles the login and makes a switchback by calling a universal link to the app.

Found anything to fixe it ? I more or less have the same issue...

namluu25 commented 1 year ago

I just gave up on this and use Linking.openURL instead. It's not so convenient on user experience but solve my problem temporary.

esbenvb commented 1 year ago

Found anything to fixe it ? I more or less have the same issue...

The auth broker we use for MitID (Criipto) had an extra URL agument you can add so it uses an https URL to switch back to the app and then the web view is redirected to a custom url scheme afterwards.

badalsaibo commented 5 months ago

Can confirm this issue. Redirects doesn't happen from the in app browser safari view to the app even when the redirect uri is a successfully registered universal link. This can be proven by clicking the link in a chat and the app being opened but the with the in app browser flow the redirect uri isn't triggering.