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

1.2k views Asked by At

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. . .

3

There are 3 answers

0
ISDr On BEST ANSWER

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

0
scott007 On

Create web app then update inside redirect url.

Please update your redirect url inside manifest it allow @, https://auth.expo.io/@username/app-slug

The same url you can use using manifest inside AZURE left side menu bellow authorization, directly update your url.

I had same issue while update direct url into redirect url, so use manifest tab

For more info : https://learn.microsoft.com/en-us/answers/questions/876955/azure-active-directory-app-registration-doesnt-acc

0
HEV Pro On

Thanks @fatihyildizhan it works!

Only for add more context if somebody needs, to get the bundle_id and not a route like expo exp://192.168.1.48:8081/auth we should create a development build to get the bundle_id correctly, here you can see how:

https://docs.expo.dev/build/eas-json/#development-builds

I hope it helps!