小编Lui*_*Gar的帖子

Firebase getIdToken不起作用

我正在使用来自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 …

javascript web firebase firebase-authentication

4
推荐指数
1
解决办法
6906
查看次数