Facebook API does not return email address

Edit: Do not duplicate because:

  • I have permission
  • Marker Debugging
  • The code works with a test user.

Please do not mark as duplicate without reading.

I am trying to get the email address of the user, but I do not understand. In the graphical api explorer, when I click send, the email field turns gray and says:

Field

empty or forbidden with an access token

But when I debug a token, it has permission to use email

My profile has an email address.

Update: I tried https://developers.facebook.com/tools/console/ . My profile returns nothing, even on another computer. But the same code returns the email address, name and ID of another account.

the code:

<fb:login-button scope="email"> Grant Permissions to make more examples work </fb:login-button> <button onclick="doPost()">Post to Stream</button> <script> function userData() { FB.api('/me?fields=name,email', Log.info.bind('/me callback')); }; FB.getLoginStatus(function(response) { if (response.status === 'connected') { userData(); } }); </script> 

Can you block your email so that no one can use it? Even when do I grant permission?

+57
javascript facebook
May 19 '13 at 2:50
source share
7 answers

After I received the error report marked as duplicate and I read all the messages and links there, I got what caused this problem for me and how to fix it.

The Facebook problem sometimes forgets that your main email is in the graphical API (but it is still present in the settings.)

Solution The consumer must delete the message, save the settings, then re-add the address, re-confirm, and then make it primary. This fixed my account both in my sandbox application and in other applications in which Facebook does not work.

+20
Oct 18 '13 at 12:50
source share

The Marcus' answer brand brings me to the real problem that I am facing.

Debugging using the tool Facebook Explorer. I was able to figure out that I should set the email scope using the FB.api() method after a successful login.

 FB.login(function(response) { if (response.status === 'connected'){ FB.api('/me?fields=id,email,name', function(data) { console.log( data.email ) // it will not be null ;) }) }, {scope: 'email'}); 

This is not entirely clear in the Quickstart manual , and I hope this helps someone else as well.

+38
Jan 25 '16 at 14:15
source share

I had the same problem and I think I found out why: If the user has an unconfirmed email on Facebook (for example, Facebook sent him a confirmation email to his email address, but he didn’t reply). Facebook will NOT send this email to your application, even if it has given you permission to email (!!!).

So what I did was his Facebook email, if he has a username (i.e. userName@facebook.com).

+33
Dec 15 '13 at 12:36
source share

The new facebook graphic requires areas added to the / me request, as shown below:

/ i = email fields, birthday, place of residence, location, age_range, currency, first_name, last_name, name_format, gender and amplifier ;? Access_token =

+6
Jan 18 '17 at 9:28
source share

I had the same problem when I was developing the fb login button for my site. I even had permission settings for my application here:

 https://developers.facebook.com/apps/<my-app-ID>/permissions 

and it worked fine for certain initial cases, that is, it provided email (I tested it on my own account, and it gave my email address). Then, suddenly, he began not to reflect any email. After two hours of viewing, I realized that there was a problem with the access token when I continued this link:

 https://developers.facebook.com/tools/explorer/<your-fb-id>/?method=GET&path=100002451127858%3Ffields%3Did%2Cemail 

Update your -fb-id with your id and follow the link above. Click Get Access Token. On the tab that opens, click "Advanced Permissions", and in this select "email" and send. Now check your request again. This will definitely work on both the console and your website. Hurrah!:)

+4
Nov 01. '13 at 9:58
source share

This is a known bug. If the user does not have an email address set to primary, the request returns null for the email. Set the email address for your account at https://www.facebook.com/settings?tab=account§ion=email&view , and then try.

Source: https://developers.facebook.com/bugs/298946933534016/

+1
Jun 13 '13 at 7:23
source share

If you have the same problem, replace your primary Facebook email address with anything, then return it. After long pulling my hair, it made me work.

0
Jan 30 '19 at 15:04
source share



All Articles