Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Active Directory B2C with react native

I did this azure ad b2c web api tutorial that get's an authorization token with postman and sends it to the API. But how do I get an authorization token from a react native app? When I create the application, do I choose 'Web App / Web API' or 'Native client'? And is there any examples / resources that I can use? Can I use this sample with Microsoft Authentication Library (MSAL)? Im confused because react native is built with JS but compiled to native code.

like image 650
thatsIT Avatar asked Oct 17 '22 21:10

thatsIT


2 Answers

Check https://github.com/GSingh01/ad-b2c-react-native. It uses latest spec from Microsoft and JS based solution thus you don't need to eject from expo.

like image 91
gsingh Avatar answered Oct 29 '22 23:10

gsingh


Assuming you plan to use the login from you RN App to both validate the user is valid and to then request data over Azure hosted API endpoints, you should setup your AD B2C Application to allow both Web\Web API AND Native Client.

If you are OK with using the web-based login from your App which jumps out to the mobile browser and then back to your app, have a look at Visual Studio App Center Auth.

NOTE: App Center Auth has been retired: https://devblogs.microsoft.com/appcenter/app-center-mbaas-retirement/

If you wish to use your own screens hosted in your RN App, you then will need to follow a JWT authentication example. Details of that would be a separate question though.

like image 36
Patrick Avatar answered Oct 29 '22 21:10

Patrick