3

I'm using Satellizer to do a Facebook login, it works great except that Facebook is not returning all the users info. I'm only getting a name and ID but no email when I inculde in my scope email and public_profile.

Here is my FB config on the client side, and as you can see, I'm asking for email and public_profile:

facebook: {
                clientId: 'xxxxxxx',
                url: '/api/public/authentication/facebook',
                authorizationEndpoint: 'https://www.facebook.com/v2.3/dialog/oauth',
                redirectUri: window.location.protocol + '//' + window.location.host + '/',  //  window.location.origin || window.location.protocol + '//' + window.location.host + '/'
                scope: 'email,public_profile',
                scopeDelimiter: ',',
                requiredUrlParams: ['display', 'scope'],
                display: 'popup',
                type: '2.0',
                popupOptions: { width: 481, height: 269 }
            },

On the server, this:

request.get( { url: graphApiUrl, qs: accessToken, json: true }, function( err, response, profile ) { ....

Only gives for the profile the id and name like so:

profile = Object {name: Denis, id: xxx}

No idea what I'm doing wrong and why I'm not getting the email, the avatar...

Thanks.

denislexic
  • 10,786
  • 23
  • 84
  • 128
  • See my Ans here http://stackoverflow.com/questions/34740186/how-to-get-email-from-facebook-through-guzzle-in-laravel I hope it will fix your problem – Niklesh Raut Jan 14 '16 at 09:14

3 Answers3

3

From Facebook API v2.4, we need to explicitly specify fields(ex:email) to get.

Introducing Graph API v2.4

So, you need to have fields as URL parameter like

"https://graph.facebook.com/me?fields=id,email,gender,link,locale,name,timezone,updated_time,verified"

Tsuneo Yoshioka
  • 7,504
  • 4
  • 36
  • 32
0

As the author of satellizer explains here

https://github.com/sahat/satellizer/issues/116

The format of the scope property should be an array of strings. So yours should be:

Scope: ['email', 'public_profile']

Hope that helps!

Joel

Joel Márquez
  • 419
  • 5
  • 8
0

In order to get email from Facebook, you must make sure that the account's email is set to public, else it won't return it.

Muhammad Ahsan
  • 249
  • 4
  • 13