Auth redirect with React Native App (Azure B2C)

Viewed 111

I'm new to React Native and I'm trying to authorize my app using Azure AD B2C and react-native-app-auth.

While the system browser is launching and I can log in, what I'm struggling with is redirecting back to the app with the correct app-scheme.

Most Azure based documentation on Android (like here, here and here) directs me to using the signature and scheme as an activity in the AndroidManifest.xml so the app can respond to the flow.

<activity
    android:name="com.microsoft.identity.client.BrowserTabActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="msauth"
            android:host="Enter_the_Package_Name"
            android:path="/Enter_the_Signature_Hash" />
    </intent-filter>
</activity>

But React Native documentation for react-native-app-auth (like here and here) say I jsut need to set the appAuthRedirectScheme in the android/app/build.grandle file.

I'm not sure which approach is appropriate and in theory this shouldn't be difficult. But when I try either method, I either get no response after successfully logging in (ie the redirect is likely happening but the App isn't listening) or the app completely hangs.

Is there any clear direction on how to get the redirect to work?

UPDATE

I read via react-native-app-auth documentation

The scheme is the beginning of your OAuth Redirect URL, up to the scheme separator (:) character. E.g. if your redirect uri is com.myapp://oauth, then the url scheme will is com.myapp. The scheme must be in lowercase.

This seems to just work differently from other Azure documents where the scheme is the package name. In my case, I had to change the scheme to msauth.

manifestPlaceholders = [appAuthRedirectScheme: 'msauth']

This works but would this not conflict for other applications? Best practice says I should make the package name unique, keeping the RedirectUri unique. But if the scheme is set to msauth, would this not conflict with other apps?

enter image description here

0 Answers
Related