getIdToken never refreshes the token client side
See original GitHub issueDescribe the bug It’s possible this is an error on my side rather than with the package. However, I think my use case is pretty simple.
I’m making an authenticated API call server side and then making the same API call client side when a user wants to refresh data on the page. The API call is to a separate (non nextjs) backend. If I open the page, leave it open for about an hour without reloading the page, and then click my refresh data button, I get the following error on my backend when verifying the ID token: ID token has expired at: 1634752738
(time changes obviously).
My API request is pretty simple, it’s just
authUser.getIdToken()
.then((token) => axios.get(url, {headers: { Authorization: token }}))
Unless I’m missing something, getIdToken
should handle refreshing the token if it has expired, per the firebase docs. It does not appear to refresh the ID token ever—I am logging the token expiration date on my backend and it only changes when I reload the page, never when I make the request client side. Even when I pass true
to force refresh the token, the expiration doesn’t change and eventually it gives me an error.
Any idea why this might be happening?
Versions
next-firebase-auth
version: ^0.13.4-alpha.0
Firebase JS SDK: ^8.6.8
Next.js: 11.0.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Thanks, I’ll dig into this as soon as I can make the time.
Closing until there’s a clear way to reproduce.