Something changed from facebook APIs v2.3 to v2.4 - after using 2.4 I can only get name and id,
I saw some posts talking about adding a "?fields=scopes..." but it's a true mystery for me - I'm trying to understand how to send these scope fields...
Here is my code:
var facebookAuthOptions = new FacebookAuthenticationOptions();
facebookAuthOptions.AppId = facebookAuthAppId;
facebookAuthOptions.AppSecret = facebookAuthAppSecret;
facebookAuthOptions.Scope.Add("email");
facebookAuthOptions.Scope.Add("user_birthday");
facebookAuthOptions.Scope.Add("public_profile");
facebookAuthOptions.Provider = new FacebookAuthenticationProvider()
{
OnAuthenticated = (context) =>
{
// https://stackoverflow.com/questions/25966530/asp-net-mvc-5-1-c-sharp-owin-facebook-authentication-or-login-ask-for-birthday/25967936#25967936
context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken));
foreach (var claim in context.User)
{
var claimType = string.Format("urn:facebook:{0}", claim.Key);
var claimValue = claim.Value.ToString();
if (!context.Identity.HasClaim(claimType, claimValue))
context.Identity.AddClaim(new System.Security.Claims.Claim(claimType, claimValue, "XmlSchemaString", "Facebook"));
}
return Task.FromResult(0);
}
};
app.UseFacebookAuthentication(facebookAuthOptions);
Thanks in advance.
UPDATE 1: I tried to inject the scope fields like this:
facebookAuthOptions.UserInformationEndpoint += "?fields=email,user_birthday,first_name,last_name";
But still not working...
UPDATE 2: I found this post that makes it possible to get the email, but I have to install additional Facebook SDK for .NET which I prefer to avoid... also found this post that shows how to extract more values like birthday (in facebook APIs v4.3 I had to send birthday and not user_birthday) dynamic myInfo = fb.Get("/me?fields=email,birthday"); I'm still looking for a way to send the scope values through the standard Oauth2 methods...
UPDATE 3: I managed to get more info using the Facebook .NET SDK - https://stackoverflow.com/a/31933544/3187389 But still prefer not be able to do that with the standard Oauth2 (and Owin) without using Facebook .NET SDK...