Skip to content

Persisting authentication state #4679

Answered by WesselKoorn
WesselKoorn asked this question in Q&A
Discussion options

You must be logged in to vote

I think I found the issue - @mikehardy thanks for your feedback.

We're using the idToken as access token for our own API, and validate that token on the backend with the Firebase Admin SDK. On the frontend we listen to the onAuthStateChanged event to retrieve the user's idToken and save the idToken in AsyncStorage. We get the idToken from AsyncStorage every time we make an API call to our own backend.

For some reason I thought that the onAuthStateChanged event would get triggered when the idToken refreshes, but this is not the case. The RNFB SDK just refreshed the token silently, and you will get the updated token when you call auth().currentUser.getIdToken(). So right now instead of gett…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@WesselKoorn
Comment options

@mikehardy
Comment options

@WesselKoorn
Comment options

@mikehardy
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by WesselKoorn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants