3

我正在使用 Satellizer 进行 Facebook 登录,除了 Facebook 没有返回所有用户信息外,它效果很好。当我包含在我的范围电子邮件和 public_profile 中时,我只得到一个姓名和 ID,但没有电子邮件。

这是我在客户端的 FB 配置,如您所见,我要求提供电子邮件和 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 }
            },

在服务器上,这个:

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

只为配置文件提供 ID 和名称,如下所示:

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

不知道我做错了什么以及为什么我没有收到电子邮件,头像......

谢谢。

4

3 回答 3

3

从 Facebook API v2.4 开始,我们需要明确指定要获取的字段(例如:电子邮件)。

介绍 Graph API v2.4

因此,您需要将字段作为 URL 参数,例如

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

于 2015-07-22T05:10:53.953 回答
0

为了从 Facebook 接收电子邮件,您必须确保该帐户的电子邮件设置为公开,否则它不会返回它。

于 2016-08-22T08:03:03.040 回答
0

正如 satellizer 的作者在这里解释的那样

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

范围属性的格式应该是一个字符串数组。所以你的应该是:

范围:['email', 'public_profile']

希望有帮助!

乔尔

于 2015-08-14T11:16:12.453 回答