1

I was using ASP.NET MVC 5 and all was working fine, now I'm working with ASP.NET Core and the social login with Facebook is not getting the email. I have tested with my account and others as well. I'm using:

"Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final"

This is the code in the Account Controller:

// REVIEW: handle case where email not in claims?
var email = loginInfo.ExternalPrincipal.FindFirstValue(ClaimTypes.Email);

Startup.cs Example:

app.UseFacebookAuthentication(options =>
            {
                options.AppId = "**********";
                options.AppSecret = "********";

            });

Any ideas how to fix it?

David Pine
  • 22,888
  • 9
  • 75
  • 103
chemitaxis
  • 12,721
  • 16
  • 70
  • 122

1 Answers1

1

The issue seems to be specific to FaceBook and is documented fairly well in github here and here. Things to ensure you have setup correctly:

  1. Ensure app status is "live" https://developers.facebook.com/apps/myappid/review-status/
  2. When invoking app.UseFacebookAuthentication ensure you add "email" to the scope like so
  3. If you're still unable, try setting fields explicitly like the example below:

Options.UserInformationEndpoint = 
   "https://graph.facebook.com/me?fields=email,timezone,picture";

If you're still not getting what you need, upgrade to RC2.

Community
  • 1
  • 1
David Pine
  • 22,888
  • 9
  • 75
  • 103