I'm trying to implement a Google authentication in a MVC 5 web app. Authentication is working fine, but I would retrieve profile and picture informations.
To do this, I added a GoogleOAuth2AuthenticationOptions object to specify additional claims :
var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions
{
ClientId = "xxxxxxxxxxxxxxxx",
ClientSecret = "xxxxxxxxxxxxxxxxx",
CallbackPath = new PathString("/Account/LoginCallback"),
Provider = new GoogleOAuth2AuthenticationProvider()
{
OnAuthenticated = async context =>
{
context.Identity.AddClaim(new Claim("picture", context.User.GetValue("picture").ToString()));
context.Identity.AddClaim(new Claim("profile", context.User.GetValue("profile").ToString()));
}
}
};
app.UseGoogleAuthentication(googleOAuth2AuthenticationOptions);
But it causes that a wrong URL is generated :
There is no '?' before parameters, that's cause a redirect_uri_mismatch.
However, when I use simply :
app.UseGoogleAuthentication(
clientId : "xxxxxxxxxxxxxxxxxxx",
clientSecret : "xxxxxxxxxxxxxxxxx");
It's working.
Any idea ?