Add a parameter in google authorization url using MVC 5
Add a parameter in google authorization url using MVC 5
I want to add the prompt
and set to select_account
parameter in the google OAuth2 authorization URL so that when the user sign-in using google it will always show the google account chooser.
prompt
select_account
I think I found a solution that I can use using OAuthEvents
for example:
OAuthEvents
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = "",
ClientSecret = "",
CallbackPath = new PathString("/GoogleLoginCallback"),
Events = new OAuthEvents()
{
OnRedirectToAuthorizationEndpoint = ctx =>
{
ctx.HttpContext.Response.Redirect(ctx.RedirectUri + "&prompt?=select_account");
return Task.FromResult(0);
}
}
});
But OAuthEvents
is only available in ASP.NET Core but the project I am developing is using .NET Framework 4.5 only. Any workaround to do this will be much appreciated. :)
OAuthEvents
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.