Facebook登录响应没有电子邮件和公共资料数据

时间:2018-08-30 12:02:51

标签: facebook facebook-javascript-sdk facebook-login

我有一个简单的登录按钮:

<div class="fb-login-button" data-width="234" data-max-rows="1" data-size="large" data-button-type="login_with" data-show-faces="false" data-auto-logout-link="false" data-use-continue-as="false" data-scope="public_profile,email" data-onlogin="system.onFacebookAuth()"></div>

简单的回调:

system.onFacebookAuth = function() {
    FB.getLoginStatus(function(response) {
        console.log(response);
    });
}

我正在尝试登录并:

{…}
authResponse: {…}
accessToken: "..."
expiresIn: 3917
reauthorize_required_in: 7775999
signedRequest: "..."
userID: "90204760053877350"
<prototype>: Object { … }
status: "connected"
<prototype>: Object { … }

仅此而已。没有电子邮件,甚至没有公开个人资料数据(例如用户名)。你能解释一下怎么了吗?

1 个答案:

答案 0 :(得分:2)

您未在代码中使用API​​。 FB.getLoginStatus仅检查用户是否对您的应用进行了授权。这将是一个API调用:

FB.api('/me', {fields: 'email,name'}, (response) => {
  console.log(response);
});
相关问题