How do I handle a JWT expiring #889
Replies: 14 comments 26 replies
-
I'm also curious about how to handle this situation, I saw that there's an option "autoRefreshToken" but it doesn't seems like working in my case, or maybe this is just referring to refreshing the token upon the first login or something, Also saw about the two API that might be able to refresh the token, but catching the error with every request feels like not the proper way to handle it...
hopefully someone will have a clear solution to this. |
Beta Was this translation helpful? Give feedback.
-
I stumbled on this issue too. Any suggestions from the Supabase team? |
Beta Was this translation helpful? Give feedback.
-
I've also encountered this. Really disappointing how important questions like this go unanswered for months. |
Beta Was this translation helpful? Give feedback.
-
hey @silentworks this should have been solved by this: supabase/auth-js#72 |
Beta Was this translation helpful? Give feedback.
-
I'm experiencing a JWT expiry issue in my SSR SvelteKit app. I have raised a support ticket. I cannot reliably reproduce the JWT expiring. It occurs in dev and in prod. supabase-js v1.28.0 My supabase auth setup is directly from https://www.ashleyconnor.co.uk/2021/06/24/authenticated-server-rendered-pages-with-sveltekit-and-supabase which does have a listed fault of |
Beta Was this translation helpful? Give feedback.
-
i was able to make it work with svelte kit. it's really ugly and i need to polish the stuff but basically i have server only endpoints in sveltekit doing all the authentication. supabase-js is never used on the client. i store access_token, refresh_token and expires_at in individal cookies (with different expirations). this allows me to still read the refresh_cookie even if the access_token is expired. then in the hooks.js file i check the access_token and refresh_token and if the access_token is expired i issue a new one via |
Beta Was this translation helpful? Give feedback.
-
Any progress on resolving this token issue? |
Beta Was this translation helpful? Give feedback.
-
OK here is the solution for the problem: https://github.com/supabase-community/supabase-auth-helpers/tree/next/src/nextjs |
Beta Was this translation helpful? Give feedback.
-
For the sveltekit folks: Supabase released its helper library now. I think using that would now be the way to go https://github.com/supabase-community/auth-helpers/tree/main/packages/sveltekit |
Beta Was this translation helpful? Give feedback.
-
In react native this sees to still be an issue, what is worse once the token expires I can't sign-out, it gives me an invalid JWT error ->
That's kind of the gist of it, I should be able to at least invalidate the session to ask for sign-in again. |
Beta Was this translation helpful? Give feedback.
-
Happening really often in a RN app. Any solutions? |
Beta Was this translation helpful? Give feedback.
-
Also related, trying to get session data (like a user id) doesn't seem to work
|
Beta Was this translation helpful? Give feedback.
-
FWIW, I have resolved this in my setup by:-
to this...
|
Beta Was this translation helpful? Give feedback.
-
this is how I am handling in my react native app
|
Beta Was this translation helpful? Give feedback.
-
I'm currently working on a SPA and I sometimes keep it open for long period on one screen, but whenever I click to a new screen and a request is made to supabase I get a 401 from the request along with "JWT Expired" message. How can I catch this from every request supabase makes in order to show a more reliable message or a user log in form.
The question is mainly how do I intercept this response from all supabase calls?
Beta Was this translation helpful? Give feedback.
All reactions