所以,我一直在我的 AngularJS/Ionic 项目中使用 Firebase,通过 Facebook 身份验证访问我的应用。
身份验证正常,它检索了一些数据(显示名称、电子邮件、urid、url 照片等),但我需要更多。
我需要获取项目的名字和姓氏,因为我需要使用它。当此人同意分享信息时,表示她正在分享她的公开个人资料,但随附的数据并没有 Facebook 文档所说的公开个人资料提供的数据。
我使用 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;
// ...
});
};
在这里登录:
所以,因为我不想使用“显示名称”。因为人们有时不会在那里使用他们的真名。
有谁知道如何使用 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/