Satellizer Facebook login not returning the right scope

爱⌒轻易说出口 提交于 2020-01-14 13:57:06

问题


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.


回答1:


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"




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/31502362/satellizer-facebook-login-not-returning-the-right-scope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!