javascript - 使用 Firebase 和 AngularJS 从 Facebook 检索公开个人资料

标签 javascript angularjs firebase firebase-authentication facebook-authentication

所以,我一直在我的 AngularJS/Ionic 项目中使用 Firebase,通过 Facebook 身份验证访问我的应用。

身份验证正常,它检索了一些数据(显示名称、电子邮件、urid、url 照片等),但我需要更多。

我需要获取项目的名字和姓氏,因为我需要使用它。当此人同意分享信息时,表示她正在分享她的公开个人资料,但随附的数据并没有 Facebook 文档所说的公开个人资料提供的数据。

here

我使用 Firebase 文档对此进行编程。有一部分说要使用 addScope 添加你想要的内容,默认情况下会询问公共(public)配置文件,但我还是添加了它。 (我无法发布链接,StackOverflow 说我的声誉太低了)。

$scope.FBLogin = function (){
firebase.auth().signInWithPopup(provider).then(function(result) {

  var token = result.credential.accessToken;
  var user = result.user;
  var profile = result.user.public_profile;
  console.log("success")
  console.log(result);
  console.log(user);


}).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // The email of the user's account used.
  var email = error.email;
  // The firebase.auth.AuthCredential type that was used.
  var credential = error.credential;
// ...
});
};

在这里登录:

Log here

所以,因为我不想使用“显示名称”。因为人们有时不会在那里使用他们的真名。

有谁知道如何使用 Firebase 和 AngularJS 检索该信息?

最佳答案

目前 Firebase 不支持此功能。您必须对 Facebook 进行额外的 API 调用才能获取该数据。

result.credential.accessToken 包含 Facebook 访问 token 。使用该访问 token ,您可以获得 Facebook 个人资料数据。以下是如何使用 Facebook 执行此操作的示例: How to get user profile info using access token in php-sdk

AJAX 获取 ' https://graph.facebook.com/me?access_token= ' + result.credential.accessToken

关于javascript - 使用 Firebase 和 AngularJS 从 Facebook 检索公开个人资料,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41594007/

相关文章:

javascript - 尽管控制台中出现错误,仍发出 CORS 请求

javascript - 如何添加隐藏的自定义属性

javascript - Js函数调用另一种方式

database - 如何使 Firebase 与另一个数据库保持同步

javascript - Fancybox2 使用 JWPlayer 6 将图像和视频放在同一组中

javascript - 如何获取 Angular 函数之外的变量值

javascript - 如何使用 AngularJS 和 CSS 滑动切换列表元素

javascript - 在 Angular 中重复一个指令

java - 当 Firebase 和 Android 中有新节点时,我的应用程序不断跳回 Activity

ios - 快速解码 httpsCallable 云函数响应