无法使用 Parse Facebook 登录获取用户的电子邮件





我正在使用Parse,我正在尝试创建一个简单的facebook登录。我的FB初始化看起来像:

window.fbAsyncInit = function() {
    Parse.FacebookUtils.init({ // this line replaces FB.init({
      appId      : 'xxxxxxxxxxxxxx', // Facebook App ID
      status     : true,  // check Facebook Login status
      cookie     : true,  // enable cookies to allow Parse to access the session
      xfbml      : true,  // initialize Facebook social plugins on the page
      version    : 'v2.3' // point to the latest Facebook Graph API version
    });
};

我的FB登录功能看起来像:

Parse.FacebookUtils.logIn('email', {
      success: function(user) {
        if (!user.existed()) {
          alert("User signed up and logged in through Facebook!");              
        } else {
          alert("User logged in through Facebook!");
        }
      },
      error: function(user, error) {
        console.log(error);
      }
});

这个流运行得很好,因为我可以看到用户是在Parse核心视图(Users表(中创建的(第一次登录时(,我可以看到Parse.user.current((是FB用户
问题是,我找不到用户的电子邮件

我试过:

Parse.User.current().getEmail(); //undefined
FB.api('/me', function(me) { console.log(me) }); //prints an object with 'name' and 'id' fields only

什么都不管用
此外,我尝试了null/'email'/'public_profile,email'作为第一个FB登录参数,但没有成功…:(

有什么想法吗

谢谢!

FB.api('/me?fields=name,email', function(me) { console.log(me) });

它被称为"声明字段":https://developers.facebook.com/docs/apps/changelog#v2_4

如果这不起作用,那么登录可能有问题。请确保您被要求获得电子邮件权限。

最新更新