Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does firebase custom authentication require that you manage refresh tokens for web clients?

For firebase, I'm using custom authentication because our organization uses CAS for single sign on.

Does custom authentication handle refresh jwt tokens automatically or would I need to develop a refresh workflow within my app?

I am not creating custom tokens using a third party library. My token is created via var token = firebase.auth().createCustomToken(uid, additionalClaims) as described on https://firebase.google.com/docs/auth/server/create-custom-tokens. But this page doesn't mention anything about refresh tokens.

My clients are mainly web, and I've found notes that if you use the Android SDK, this refresh happens automatically. But I'm unsure about refresh tokens and web clients for custom authentications.

like image 976
Kevin Avatar asked Dec 25 '22 00:12

Kevin


1 Answers

After you create the custom token using createCustomToken, you pass that token to the web client and call firebase.auth().signInWithCustomToken(token). The promise returned will resolve with a firebase User. The onAuthStateChanged listener will trigger as expected. A firebase Id token will be available. The token will be refreshed every hour and will be handled by the Firebase SDK. Anytime you call a user method or getToken on user, the token will be automatically refreshed if the old one was expired.

like image 82
bojeil Avatar answered Dec 28 '22 08:12

bojeil