According to the documentation of firebase.User:getIdToken() :
Returns the JWT token used to identify the user to the Firebase service.
Returns the current token, if it has not expired, otherwise it will update the token and return a new one.
The method returns a promise, as it may require a return pass to the Firebase servers if the token expired:
Auth.currentUser.getIdToken().then(data => console.log(data))
Or in more classic JavaScript:
Auth.currentUser.getIdToken().then(function(data) { console.log(data) });
Log output:
eu ... Bipa
Refresh . To verify that the user has been signed before receiving the token, run the above code in the onAuthStateChanged listener :
firebase.auth().onAuthStateChanged(function(user) { if (user) { user.getIdToken().then(function(data) { console.log(data) }); } });
source share