我正在使用来自JavaScript客户端的Firebase身份验证进行测试,并且正在尝试使用客户端文档上的检索ID令牌来检索IDToken
我想我忘记了一些基本的知识。
用户已使用Google登录
The code is just i've seen in other posts and in the documentation. And the result is in the comments.
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
console.log(user); // this is shown. Firebase user and provider data
console.log(user.uid); // Shown
firebase.auth().user.getIdToken().then(function(idToken) {
console.log(idToken+'--'); // Nothing happens. No errors and the function not continues
});
console.log(user.uid); // Nothing happens
}
})
Run Code Online (Sandbox Code Playgroud)
Thanks
EDIT:
if I add anything wrong nothing happens too. for example if I add an alert …