问题描述
在 AngularFire 中,您可以为经过身份验证的用户访问提供程序(例如 Google)的 accessToken.
In AngularFire you were able to access the providers (e.g Google) accessToken for the authenticated user.
似乎没有办法使用 AngularFire2 访问它?
There does not seem to be a way to access this with AngularFire2?
在初次登录时这样说:
this.af.auth.subscribe(user=> {
if (user) {
console.log(user.google);
}
});
它会注销 idToken、accessToken、provider、但是(在页面刷新时)随后将注销标准详细信息(uid、displayName 等....)而且 accessToken 不是可访问的属性?
It will log out the idToken, accessToken, provider,But (on a page refresh) subsequently will log out the standard details (uid, displayName etc....)And the accessToken is not an accessible property?
有没有办法访问当前用户的accessToken?
Is there a way to access the current users accessToken?
推荐答案
getToken
现已弃用.您应该使用 getIdToken
代替:
getToken
is deprecated now. You should use getIdToken
instead:
this.af.auth.currentUser.getIdToken(true)
.then((token) => localStorage.setItem('tokenId', token));
这篇关于如何在 AngularFire2 中获取当前用户的访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!