[英]Firebase 3 - javascript - get facebook accessToken after login
In Firebase 2 I was able to get facebook accessToken
from anywhere after login by this way, just using the firebase reference , eg: 在Firebase 2中,我可以通过这种方式从登录后的任何地方获取facebook accessToken
,只需使用firebase引用 ,例如:
firebase.getAuth().facebook.accessToken
Now, how can I get that in version 3 (web)? 现在,我怎样才能在版本3(Web)中获得它?
Note, I need it outside of the Promise signInWithPopup
注意,我需要在Promise signInWithPopup
Thanks 谢谢
Try this: 尝试这个:
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Facebook Access Token. You can use it to access the Facebook API.
var token = result.credential.accessToken;
})
The easiest way to get the user access token is to use the FB API
itself. 获取用户访问令牌的最简单方法是使用FB API
本身。
Simply follow this guide on how to include it and then get the token the following way: 只需按照本指南了解如何包含它,然后按以下方式获取令牌:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var accessToken = response.authResponse.accessToken;
}
} );
可能的答案是取消链接“auth.currentUser.unlink(provider)”提供程序,并在每次需要获取访问令牌时重新链接“auth.currentUser.linkWithPopup(provider)”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.