Closed Kasonz closed 3 years ago
Hey @Kasonz
Please excuse my late response - have you found a solution to your problem already?
I have setup a similar demo project that is pretty much doing the same as your project here: https://github.com/lupas/nuxt-firebase-server-auth-demo
You are right - onAuthStatusChanged
is not triggered when the idToken expires. This is something Firebase changed with v4.0.0, when they introduced onIdTokenChanged()
for handling this case.
See onidtokenchanged vs onauthstatechanged.
This module - so far - does not implement onIdTokenChanged()
for you. So your solution would be to manually setup that listener and refresh the user/token when this action is triggered.
We intentionally do not automatically call onIdTokenChanged
, because we expect most of our users to use other Firebase JS SDK services which do not rely on this action, because the SDK automatically refreshes the idToken in that cases if expired.
So solution for you at this point: Implement the onIdTokenChanged
listener yourself.
Note/ToDo for myself:
onIdTokenChanged
instead of onAuthStatusChanged
for such casesHope that helps, I keep this issue open as a Feature request.
BR, Pascal
@Kasonz Implemented this as a feature in v7.4.0, you can now define a store mutation or action that gets triggered when onIdTokenChanged()
is triggered by Firebase. Using the options sets up the handler in the background.
Handling is exactly the same as with onAuthStateChanged
- except that after one hour the function gets triggered.
Hope that helps!
br, Pascal
Hi there,
Great module first of all!
We are looking for using nuxt-firebase to replace our custom logic + firebase package. I have read the document and played around.
Can you please help here?
let's say the app is configured as service worker + SSR: true
Is there a possibility service worker or nuxt-firebase to auto-detect & auto-refresh the id token in the request header? I only see it auto-inject in HTML page
Many thanks