react-nativeauthenticationazure-active-directoryexpomicrosoft-oauth

Advice on how to set single redirectURL for EXPO react native app for use with MS Azure AD Authentication


I'm using Expo to get started with an app which authenticates with Azure AD Oauth as per: https://docs.expo.dev/guides/authentication/#azure

It works with a single redirect URL exp://host:port with Expo Go.

However, when I build the app, I simply change the redirectURL to the bundle id e.g. com.xyx.poc . . .I really don't know what redirect URL to set in the Azure Portal (app registrations) . . . .

Do I use a web redirect URL or a iOS / Android platform redirect URl? And what value do I set it to? I've tried a tonne of things e.g.

msauth://code/msauth.com.xyz.poc%3A%2F%2Fauth
msauth.com.xyz.poc://auth
msauth.com.xyz.poc

Please help. . . . I just need to know what to set up in app.json / relevant tsx where the auth component lies and what to set up in the Azure Portal / App Registrations section for redirect URL. . .


Solution

  • I managed to figure this out after over a day of tweaking and reading. Wish it was clearer, but here goes:

    I set the redirect_uri as follows:

    redirect_uri: makeRedirectUri({ scheme: '<bundle_id_here>', path: 'auth' }),
    

    My expo.scheme was set to just: "<bundle_id_here>"

    In Azure, under App Registrations, Authentication, I put in a "web and desktop application" redirect URL as: <bundle_id_here>://auth