@James Hamil , first of all thank you for replying to my post.
I am not using redirects on the logout since what I have is implemented on React Native which is for mobile apps.
Here's the link where I raised what I encountered to the authors of the library.
https://github.com/vmurin/react-native-azure-auth/issues/122#issuecomment-887259715.
I also assumed that this might be a bug in the library that was used but I was told different. This is also not confirmed as a bug or issue on Azure or Microsoft so I want to reach out here first.
The logout code is very much the same as what is shown in the read me or example of the library that I used. The _onLogout routine is called when the user taps the logout button in the mobile app, below is the simplified code.
import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import AzureAuth from 'react-native-azure-auth';
import AsyncStorage from '@react-native-async-storage/async-storage';
const _clientId="some client id"
const _tenant = 'some tenant id'
const _redirectURI = 'com.somename://com.somename/ios/callback'
const azureAuth = new AzureAuth({
clientId: _clientId,
tenant: _tenant,
redirectUri: _redirectURI
});
export default class AzureAuthentication extends Component {
constructor(props) {
super(props);
this.state = { accessToken: null, user: '' , mails: [], userId: ''};
}
_onLogin = async () => {
try
{
let tokens = await azureAuth.webAuth.authorize({scope: 'openid profile User.Read', prompt: 'login'})
this.setState({ accessToken: tokens.accessToken });
let info = await azureAuth.auth.msGraphRequest({token: tokens.accessToken, path: 'me'})
var displayName = info.surname + ", " + info.givenName;
}
catch (error)
{
console.log('Error during Azure operation', error);
}
}
_onLogout = () => {
azureAuth.webAuth
.clearSession({closeOnLoad: true})
.then(success => {
this.setState({ accessToken: null, user: null });
})
.catch(error => console.log(error));
AsyncStorage.clear();
};
}
AppRegistry.registerComponent('AzureAuthentication', () => AzureAuthentication);
Below is the code when the logout button is tapped by the user.
const logout = async () =>
{
try
{
navigation.navigate("LoginPage");
var _azureAuth = new azureAuth();
_azureAuth._onLogout();
}
catch (e)
{
console.log (e.message);
}
};