User-1706174896 posted
Hi,
I'm trying to get the external login working with UseFacebookAuthentication and hit a roadblock. Facebook authenticates the user and my Web APP gets the authenticated callback but the context Email is always null. I've requested it through the scope and
the login states that the users email will be provided to the app but its not present in the response.
I've dug pretty deep into the FacebookAuthenticationHandler source code and found that there appears to be an incorrect call to "https://graph.facebook.com/me". I don't think the email will ever be returned without "?fields=id,name,email".
The following code snippet is how I'm setting up the external auth.
var fbOptions = new FacebookAuthenticationOptions
{
AppId = "xxxxxxxxxxxxxxxx",
AppSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
Scope = { "email", "user_friends", "public_profile" },
SignInAsAuthenticationType = Microsoft.Owin.Security.AppBuilderSecurityExtensions.GetDefaultSignInAsAuthenticationType(app),
Provider = new FacebookAuthenticationProvider()
{
OnAuthenticated = (context) =>
{
// Add the email id to the claim
context.Identity.AddClaim(new Claim(ClaimTypes.Email, context.Email));
return Task.FromResult(0);
}
}
};
app.UseFacebookAuthentication(fbOptions);
Has anyone ever gotten this to work?
If so, what am I doing wrong?
Should I just write my own Facebook handler?