admin管理员组文章数量:1410682
UPDATE It seems that my personnal email address had not been used for years. Facebook marked it as inactive and did not return it as part of the JSON.
I am authenticating a user with Facebook on the client side using this url :
?
client_id=xxx&
redirect_uri=.html&
scope=email
I receive a code I then exchange for a token :
?
code=xxx&
client_id=xxx&
client_secret=xxx&
redirect_uri=xxx
I then send the token to my server and I fetch the Fb Graph in order to get some user info, including the email.
For some reason, I get all the user 'about' info, but not his/her email!
What did I do wrong?
UPDATE It seems that my personnal email address had not been used for years. Facebook marked it as inactive and did not return it as part of the JSON.
I am authenticating a user with Facebook on the client side using this url :
https://www.facebook./dialog/oauth?
client_id=xxx&
redirect_uri=https://www.facebook./connect/login_success.html&
scope=email
I receive a code I then exchange for a token :
https://graph.facebook./oauth/access_token?
code=xxx&
client_id=xxx&
client_secret=xxx&
redirect_uri=xxx
I then send the token to my server and I fetch the Fb Graph in order to get some user info, including the email.
https://graph.facebook./me?access_token=xxx
For some reason, I get all the user 'about' info, but not his/her email!
What did I do wrong?
Share edited Nov 1, 2013 at 19:02 Justin D. asked Aug 22, 2013 at 18:18 Justin D.Justin D. 4,9767 gold badges39 silver badges70 bronze badges 4- 1 Look here: stackoverflow./questions/9347104/… – Sebastien C. Commented Aug 22, 2013 at 18:38
- I tested with my own facebook account and the address I signed up with has not been used in years! It may very well be the cause. – Justin D. Commented Aug 22, 2013 at 18:53
- If you use version 2.4, then you must request the email in the fields=... variable (and any other public profile fields). Otherwise /me would give you just the name and id – PalDev Commented Sep 23, 2015 at 5:21
- @PalDev, wish i had found your answer before i wasted half a day to work it out myself in 2020. Facebook docs still dodgy, they still have not updated to say this is the case in 2020 (or 2015 as per your answer !) – joedotnot Commented Jun 13, 2020 at 18:23
1 Answer
Reset to default 5According to the Facebook Documentation:
By default, not all the fields in a node or edge are returned when you make a query. You can choose the fields (or edges) you want returned with the "fields" query parameter. This is really useful for making your API calls more efficient and fast.
This is valid from v2.4, (previous versions retrieved some default fields).
When you register a new app you are entitled automatically (without manual review) to three permissions: email, public_profile and user_friends. In your code "email" is in scope (which is good) so just change your query to:
https://graph.facebook./me?access_token=xxx&fields=email
You probably wanted the public_profile fields that you automatically got in previous versions of the API. Do so so, add "public_profile" to your scope:
https://www.facebook./dialog/oauth?
client_id=xxx&
redirect_uri=https://www.facebook./connect/login_success.html&
scope=email,public_profile
And now add the user name fields to your query:
https://graph.facebook./me?access_token=xxx&fields=first_name,last_name,gender,email,timezone,age_range,verified
Good luck
本文标签: javascriptFacebook Graph not returning emailStack Overflow
版权声明:本文标题:javascript - Facebook Graph not returning email - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744950845a2634073.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论