Firebase - Losing Auth Session After An Hour

Viewed 1494

I added Firebase auth to my Reactjs (and Redux) web app and everything works perfectly. I'm using email / password sign in, and call firebase.auth().signInWithEmailAndPassword which persists on reloads, tab changes, etc. However, after about an hour, the auth session appears to expire and currentUser is set to null. It feels like there should be a setting somewhere in the Firebase console, but after searching through it, I can't find anything.

Any help would be really appreciated!

1 Answers

I had the exact same issue, onAuthStateChanged was always triggered after 1 hour and the user was disconnected. And firebase.auth().currentUser.getIdToken(true) didn't help either, all because... Token Service API had to be enabled for my Google API key in the Google console. Problem solved!

Go to Google Cloud platform, type "Token Service API" in the search bar, click on it in the results, and click "Manage" on the new page, and finally "Enable API".

Related