-
Notifications
You must be signed in to change notification settings - Fork 597
Can't get email claim from Facebook #435
Comments
I don't think so? It's sending a well-formed request to FB:
But I don't see the middleware asking for email anywhere, and FB is just returning id and name. I'm not familiar enough with FB graph API to know if FB should be returning email by default, or if the middleware needs to ask for it specifically. EDIT: I wonder if it's related to this SO question |
Need to try to repro this. It might be due to the user marking their email address as hidden data, so even if you request it, it won't be available. |
Yes I have the same issue, can't get email from Facebook if I just add services.Configure<FacebookAuthenticationOptions>(options =>
{
options.AppId = Configuration["Authentication:Facebook:AppId"];
options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
options.Scope.Add("email");
}); I could see that Facebook asks me for permission to provide email to the webapp but I just don't have the claim in info.ExternalPrincipal |
Hi, I'm hitting the same issue. Were you guys able to find any workarounds? Thanks! |
@hajjat @AlexTo @MikeWasson I got it to work in beta8 by changing the configuration to app.UseFacebookAuthentication(options =>
{
options.AppId = "xxx";
options.AppSecret = "yyyyy";
options.Scope.Add("email");
options.BackchannelHttpHandler = new HttpClientHandler();
options.UserInformationEndpoint = "https://graph.facebook.com/v2.5/me?fields=id,name,email";
}); |
@Jayman1305 Thanks for posting your solution, works a treat. |
@Jayman1305, I can't seem to get first_name, last_name, user_birthday using the same technique in beta8 |
First and last name come in as a single, combined field... it's just called 'name' if I remember - check the returned claim object. It's already there. You only get an age range by default. You've gone through the review process with Facebook to have your app specifically granted access to request birthdays right? (even this may not include year). |
@dotnetshadow You won't get birthday without additional authorisation. Test out the data you want in the graph explorer to see what you can get. https://developers.facebook.com/tools/explorer/ {
"error": {
"message": "(#100) Tried accessing nonexisting field (user_birthday) on node type (User)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "H+EvezAKOau"
}
} |
@chris02031 @Jayman1305 The only way I've been able to get these fields is by using the Facebook SDK nuget package and passing the access token then I can read the fields. The only issue with this is that it's not supported in dnx core 5
Controller:
|
Looks like you've got the .Scope additions, but you've missed extending the UserInformationEndPoint. options.UserInformationEndpoint = "https://graph.facebook.com/v2.5/me?fields=id,name,email,birthday"; |
@chris02031 Thanks for replying, what I mean is when I use the Facebook Client, I don't even have to add birthday to the userinformationendpoint because I'm able to grab it through the Facebook Client. I want to eliminate the Facebook client nuget package and just try reading the fields first_name, last_name or birthday, I haven't found a way of doing this yet. |
https://developers.facebook.com/docs/apps/changelog
|
@Tratcher (We are using RC1-final, and can't upgrade to RC2 until there will be VS tooling support for RC2) I'm using the same code suggested earlier by @Jayman1305 to get the first_name, last_name, email and significant_other of the user:
This solution indeed returns the email of the user, but fails with first_name,last_name and significant_other (and any other field I tried besides name, id and email). Also, is it possible getting the FB access token? We might need it for future querying of other edges. I need a way, even if not the cleanest, to get this information on RC1. Many thanks. |
I agree it would be great to just see a very simple example of using the facebook stuff in asp.net core where you can define x number of fields, i.e. last_name, first_name, birthday options.Scope.Add("last_name") and just see the results come back without using any other nuget packages. |
@dotnetshadow from reading the conversation on the pull request, it's clear it's only for first+last names. |
@gdoron Ahh ok and by manual configuration you mean I haven't kept up with how it's changed from RC1 |
Using beta7 packages. In my startup:
However, inside AccountController.ExternalLoginCallback, I get back these claim types in the ExternalPrincipal:
In the Fiddler traffic, I can see that it’s calling the FB Graph API and getting:
If I modify the request to ask for email and replay it, then I do get the email, so I think my scope is correct
Response:
The text was updated successfully, but these errors were encountered: