The Firebase SDK automatically refreshes the ID token behind the scenes. In fact, you don't have to (and probably shouldn't here from the looks of it) pass true
into getIdToken()
as it will return a valid token even when you pass false
.
While it may be possible to refresh the token on the server, it is pretty uncommon. I strongly recommend that you leave the token refresh to the client-side SDK, and simply use the token on the server to verify the user.
So more concretely: just pass false
into getIdToken(false)
and leave it to the Firebase SDK to handle the refreshing of the ID token behind the scenes.
firebaseUser.getIdToken(false).addOnSuccessListener(getTokenResult...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…