This example shows one way to integrate Azure Active Directory with React-admin.
Disclaimer: This may not be the perfect implementation but it worked for my personal use case. I am not a Javascript developer so YMMV!
This example uses the MSAL.js 2.0 libraries:
To run this example you need to set up a SPA application in Azure AD:
Then set up a local .env file that contains the Tenant ID and Client ID of this app:
REACT_APP_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
REACT_APP_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
OR alternatively replace the corresponding process.env variables in src/authConfig.js
In this example we call the generic JSONPlaceholder API and are passing the token in dataProvider.js
Although JSONPlaceholder does not require authentication, we can see the bearer token successfully being passed by inspecting the Request Headers via devtools: