How to get the ID token from FirebaseAuth

后端 未结 4 1215
星月不相逢
星月不相逢 2021-02-01 23:43

I am reading some Json files from my firebase database and I am trying to obtain an ID token for the current user to be used in the header as follows:

 var respo         


        
4条回答
  •  粉色の甜心
    2021-02-01 23:53

    I think that there is a bug in Flutter.

    Now to call the method getIdToken() you need to do this:

    FirebaseUser user = await FirebaseAuth.instance.currentUser();
    
    String token;
    
    user.getIdToken().then((result) {
    
        token = result.token;
    });
    

    You can't call FirebaseAuth.instance.currentUser().getIdToken()

提交回复
热议问题