Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook api not returning email

I am trying to return user email address using facebook api. Few days ago it was working fine, but today stopped working, and don't know why.

So first I get access token:

FB.login(response => {
    if (response.authResponse) {
      resolve(response.authResponse.accessToken);
    } else {
      reject({
        error: 'User cancelled login or did not fully authorize.'
      });
    }
  }, {
    scope: 'public_profile,email'
  });

then I try to get user data

FB.api('/me', {fields: 'first_name,last_name,email'}, function(response) {
  console.log(response);
});

but I only get data for first_name and last_name. There is no email.

Also when I ask for permissions, it gives me email as granted, but as I said, email is not returned.

FB.api('/me/permissions', function(response) {
  console.log(response);
});

Does anyone knows what can be the problem?

BTW: I am using API v2.4.

like image 342
user232343 Avatar asked Oct 18 '15 01:10

user232343


1 Answers

FB.api('/me?fields=email,name', function(response) { /* stuff here */ });

Try adding your return fields to your request.

like image 199
stillatmylinux Avatar answered Nov 14 '22 22:11

stillatmylinux