1

As per this you can use the prompt querystring to tell google oauth that you'd like the user to choose the user account.

Can someone tell me how to do this in asp.net core - if you're using the AddGoogle code as per:

.AddGoogle(GoogleDefaults.AuthenticationScheme, googleOptions =>
{
    googleOptions.ClientId = "***";
    googleOptions.ClientSecret = "***";
    googleOptions.AccessType = "offline";

    googleOptions.UserInformationEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo";
    googleOptions.ClaimActions.Clear();
    googleOptions.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
    googleOptions.ClaimActions.MapJsonKey(ClaimTypes.Name, "name");
    googleOptions.ClaimActions.MapJsonKey(ClaimTypes.GivenName, "given_name");
    googleOptions.ClaimActions.MapJsonKey(ClaimTypes.Surname, "family_name");
    googleOptions.ClaimActions.MapJsonKey("urn:google:profile", "link");
    googleOptions.ClaimActions.MapJsonKey(ClaimTypes.Email, "email");
})
Matt Roberts
  • 26,371
  • 31
  • 103
  • 180

1 Answers1

3

I've recently had the need to do this too.

Try this:

googleOptions.AuthorizationEndpoint += "?prompt=consent";
scgough
  • 5,099
  • 3
  • 30
  • 48
  • This will add the consent flow, not account selection. – DavidG Mar 20 '19 at 16:53
  • Works for me. Their [docs](https://developers.google.com/identity/openid-connect/openid-connect#authenticationuriparameters) also mention `prompt=select_account` for account selection. – JvR Jun 14 '23 at 09:28