问题描述
在AngularFire中,您可以访问提供者(例如Google)的accessToken。使用AngularFire2似乎没有办法访问
在初始登录时会这样说:
this.af (用户){
console.log(user.google);
}
});
它将注销idToken,accessToken,provider,
但是(在页面刷新)随后会注销标准的细节(uid,displayName等....)
而accessToken不是一个可访问的属性?
有没有办法访问当前用户的访问权限?
getToken
现在不推荐使用。您应该使用代替:
this.af.auth.currentUser.getIdToken(true)
.then (token)=> localStorage.setItem('tokenId',token));
In AngularFire you were able to access the providers (e.g Google) accessToken for the authenticated user.
There does not seem to be a way to access this with AngularFire2?
On initial login say like this:
this.af.auth.subscribe(user=> {
if (user) {
console.log(user.google);
}
});
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?
Is there a way to access the current users accessToken?
getToken
is deprecated now. You should use getIdToken
instead:
this.af.auth.currentUser.getIdToken(true)
.then((token) => localStorage.setItem('tokenId', token));
这篇关于如何在AngularFire2中获取当前用户的访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!