Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

How can I get user email with External Login UseFacebookAuthentication

$
0
0

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?


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>