Firebase Token Expire in hour how to get user details in SSR #32761
Replies: 4 comments
-
Hey Rajat, you might want to look into a more long lived credential such as the refresh token. Firebase times out the IdToken on purpose so as to Hopefully this helps 😃 |
Beta Was this translation helpful? Give feedback.
-
I am not able to find any working solution after googling also nothing solid working example to handle firebase auth on node server with SSR. will be able to get it working for one hour by this solution in the below link but I want to persist it until the user explicit signout or for long-duration like 14 days at least https://colinhacks.com/essays/nextjs-firebase-authentication |
Beta Was this translation helpful? Give feedback.
-
Firebase auth uses one hour id tokens yeah. Need connection to firebase to refresh it. Don't think it supports using the refresh token as main token, due to obvious issues with long lasting JWTs. |
Beta Was this translation helpful? Give feedback.
-
A little late to the party but this might help: https://stackoverflow.com/questions/62696292/how-to-reconcile-firebase-auth-token-refreshing-with-server-side-rendering |
Beta Was this translation helpful? Give feedback.
-
Currently working with the app where I need to fetch users at getServerSideProps (at SSR) and send details to the client.
For which I am using firebase admin SDK which has a method
verifyIdToken
where we pass the token and It will return us all the user details it works fine when the token is valid but here token get expire in one hour and it will throw an error token expire than we will get the new token from the client byonAuthStateChanged
and again it will work as expected for an hour.Is there any way where we can continue with the flow even after the token get expire otherwise it will have some delay until the client gets rendered and the hook is going to run to get the user details?
Beta Was this translation helpful? Give feedback.
All reactions