I am trying to authenticate my ios and android app with microsoft office 365 using react-native-app-auth package and not sure why it is not returning the token.
Here is the config that I am using:
const config = {
issuer:
'https://login.microsoftonline.com/{tenant-id}/v2.0',
clientId: '{client-id}',
redirectUrl: 'msauth.org.xxx.xxx://auth', // I got this from Azure
scopes: ['openid', 'profile', 'email', 'offline_access'],
};
I have also tried with the below config
const config = {
clientId: AuthConfig.appId,
warmAndPrefetchChrome: true,
redirectUrl: 'msauth.org.xxx.xxx://auth',
scopes: AuthConfig.appScopes,
additionalParameters: {prompt: 'select_account'},
serviceConfiguration: {
authorizationEndpoint:
'https://login.microsoftonline.com/'
AuthConfig.tenantId
'/oauth2/v2.0/authorize',
tokenEndpoint:
'https://login.microsoftonline.com/'
AuthConfig.tenantId
'/oauth2/v2.0/token',
},
};
Here is the code:
const loginWithOffice365 = async () => {
try {
let result = await authorize(config);
console.log('result', result); // This is not showing any result and not even printing any error
} catch (error) {
console.log('error', error);
}
}
I have registered the app correctly in Azure and this is the redirect url screenshot
It goes to office 365 page and I can enter my credentials and it says are you ready to login and I click continue, once I do that, it goes back to the login page. I am not sure if my redirect URL is correct because I am trying to print the token that I should get back from Microsoft.
I am just trying to print the access token. Can you please help and tell me how can I fix this?
CodePudding user response:
Your redirect url should be msauth.org.xxx.xxx://auth/
You are just missing an extra '/'