3

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.

prem_kumar
  • 124
  • 1
  • 10
  • I think this is expected behavior https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#logoutredirect see more about this here. – GRD Mar 04 '22 at 12:40
  • Hi @GRD Thanks for the quick reply. Is there any way to bypass it? – prem_kumar Mar 04 '22 at 13:11
  • If you click on above doc link, then you can find link of `Configuration options`, May be there you can find out more options, But I am not sure about it. – GRD Mar 04 '22 at 13:14

1 Answers1

3

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 });

Ref: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#promptless-logout

Ε Г И І И О
  • 11,199
  • 1
  • 48
  • 63