使用 Facebook 的 Angularfire 登录未获得扩展权限

Angularfire login with Facebook not recieving extended permissions

在升级到 angularfire 0.9 之前我已经完美地工作了

我想从 facebook 请求用户的电子邮件地址。 Facebook 已经允许我向我的用户索要这个。我正在使用下面的代码登录 facebook。这一切都完美地接受它不请求用户的电子邮件。

仅供参考:我正在使用 Angularfire-seed 代码库

loginWithFacebook: function() {
      return auth.$authWithOAuthPopup("facebook", function(error, authData) { /* Your Code */ }, {
        remember: "sessionOnly",
        scope: "email, user_likes"
      });
    },

提前致谢!


为了回应 Mike 在下面的回答,我注意到该函数根本没有 运行。不确定是什么问题。

var ref = new Firebase("https://<your-firebase>.firebaseio.com");
ref.$authWithOAuthPopup("facebook", function(error, authData) {

   //THIS CODE NEVER RUNS

   if (error) {
      console.log("Login Failed!", error);
   } else {
      console.log("Authenticated successfully with payload:", authData);
   }
});

像这样尝试,如果这不起作用,请确保更新所有的 firebase 和 angularfire。

var ref = new Firebase("https://<your-firebase>.firebaseio.com");
ref.authWithOAuthPopup("facebook", function(error, authData) {
  if (error) {
    console.log("Login Failed!", error);
  } else {
    console.log("Authenticated successfully with payload:", authData);
  }
});

我刚刚遇到了这个完全相同的问题。 AngularFire $authWithOAuthPopup 似乎没有 运行 函数中的代码或从 Facebook 请求电子邮件身份验证。我的临时解决方法是使用 authWithOAuthPopup(即没有“$”),因为 AngularFire 包装器似乎有问题。

$authWithOAuthPopup 接受选项。

也最好按照文档示例执行:

$scope.authObj.$authWithOAuthPopup("facebook",{remember: "sessionOnly",scope: "email,user_friends"}).then(function(authData) {
    console.log("Logged in as:", authData.uid);
}).catch(function(error) {
  console.error("Authentication failed:", error);
});