Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm using the Firebase email/password authentication. After the user has signed in successfully I query the access token the following way:

FirebaseUser mUser = FirebaseAuth.getInstance().getCurrentUser();
mUser.getIdToken(true)
    .addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
    public void onComplete(@NonNull Task<GetTokenResult> task) {
        if (task.isSuccessful()) {
            String idToken = task.getResult().getToken();
            // Send token to your backend via HTTPS
            // ...
        } else {
            // Handle error -> task.getException();
        }
    }
});

According to the Firebase documentation the access token expires after 1 hour. To handle the case to have always the current access token in my app, I was looking for a solution and I found in the firebase documentation that I have to register a Firebase.IdTokenListener to listen to the

onIdTokenChanged event

My question is: Is the

onIdTokenChanged event

automatically fired if the access token expired?

In case the event is not automatically fired after the access token has expired, what would be the coorect approach to query "manually" for a new/updated Access token with the

"FirebaseAuth.getInstance().getCurrentUser().getIdToken(boolean)"

method?

I know, that If I call the

mUser.getToken(true)

then the mentioned event is fired and the

IdTokenListener

is triggered. But this is not what I'm looking.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
252 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...