Hey Aruna kumar
Lemme give you a short overview on this, firstly you need an azure Active Directory AD for handling user authentication.
- Go to the Azure Portal.
- Go to Azure Active Directory > App registrations.
- Click on "New registration" and fill in the necessary details.
- Note down the Application (client) ID and Directory (tenant) ID.
So the AD is taken care of, now the next part is configuring auth in AD
In the Azure AD App Registration, go to the "Authentication" tab.
Add a Redirect URI for your app, typically in the format https://yourappname.expo.dev
.
And now set up your React Native Expo App, Install the necessary packages. For Azure AD, you can use the react-native-app-auth
library.
npm install react-native-app-auth
Now Initialize the library with your Azure AD configuration in your React Native app.
import { authorize } from 'react-native-app-auth'; const config = { issuer: 'https://login.microsoftonline.com/{your-tenant-id}', clientId: '{your-client-id}', redirectUrl: 'https://yourappname.expo.dev', scopes: ['openid', 'profile', 'email'], serviceConfiguration: { authorizationEndpoint: 'https://login.microsoftonline.com/{your-tenant-id}/oauth2/v2.0/authorize', tokenEndpoint: 'https://login.microsoftonline.com/{your-tenant-id}/oauth2/v2.0/token', }, }; async function signIn() { try { const result = await authorize(config); console.log('Authorization Result:', result); } catch (error) { console.error('Authorization Error:', error); } }
Use the signIn
function to trigger the Azure AD authentication flow.
javascriptCopy code
<Button title="Sign In" onPress={signIn} />
If this helps kindly accept the answer thanks much.