I am using the @azure/msal-angular version 2 and Angular version 13. The scenario is when the user signed in to the application need to authorize the user if he doesn't have access need to sign out the user from the application. which will be happened in background by calling msalService.logoutRedirect(). While calling the logout function the microsoft account selection screen is displayed to signout instead of auto signout. Is there any way to skip the account selection screen to siignout.
Bypass the account selection screen while sign out(log out) @azure/msal-angular V2
Asked Answered
To do this, first you have to setup the login_hint
optional claim in the ID token. That needs to be done on the app registration side of things. (Azure Portal -> App Registration -> Token Configuration -> Add Optional Claim -> ID -> login_hint)
Once that claim is in place, MSAL will pass that into logoutRedirect()
and will skip the account picker prompt.
const account = this.msalService.instance.getActiveAccount();
this.msalService.logoutRedirect({ account: account });
Do you know why this is a must have claim for automatic logout? I mean in the end there is a setActiveAccount that can be used to specify the account to redirect. Why also a custom claim? (BTW thanks it worked for me) –
Scapegrace
As mentioned here in the documentation: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#skipping-the-server-sign-out You may logout from your application without affecting their login status in other applications
msalInstance.logoutRedirect({
onRedirectNavigate: (url) => {
// Return false if you would like to stop navigation after local logout
return false;
}
});
© 2022 - 2024 — McMap. All rights reserved.
Configuration options
, May be there you can find out more options, But I am not sure about it. – Wallpaper