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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With