How to refresh a session in v2
Since this got merged, I can't figure out how to refresh a session. The new
setSession()
will only refresh your tokens if the access_token
has expired. Before this merge, setSession()
would give you new tokens even if the access_token was still valid.
Or am I just missing something? (the most likely scenario)
https://github.com/supabase/gotrue-js/pull/467GitHub
feat: update setSession by kangmingtay · Pull Request #467 · supaba...
What kind of change does this PR introduce?
Fixes setSession to make it safe to use in a server-side or SSR context
setSession should take in an access token and refresh token and only perform a r...
7 Replies
Believe I figured this out. For
setSession()
to properly refresh tokens, pass the autoRefreshToken
and persistSession
options. It may be enough to only set autoRefreshToken
- didn't experiment. It'll refresh once the tokens are expired.
Thanks, I have the same "issue" :p
I have the same auth config (using supabase in Remix, server-side) but it doesn't solve my problem.
What works is to set an empty string for the
access_token
😂
My use case : I want to force refresh x minutes before it expires because I don't want it expires in fiew ms in my api using the access token 😅Oh wow! I'll test that as well, because I also want the token to refresh before it expires.
Either way, it seems like there's some work they need to do on this.
Yes, that worked for me too! If this is the way it's designed to work, they should have a better explanation in the docs.
Does anyone know the reason why my cookies aren't set when I sign in
Depends on what framework you use. If it's Remix, I can help, otherwise, I think I saw an issue on GitHub for Nextjs
I ask, just in case ^^" https://github.com/supabase/gotrue-js/pull/467#issuecomment-1279024940
Nextjs
Do you have the link for the issue
Please
sorry I miss a notification. Hum I can't find something specific to your issue in particular 😬.
Dependening what you are doing and what you use but v2 has some breaking changes https://supabase.com/docs/reference/javascript/release-notes
Release Notes | Supabase
Supabase.js v2 release notes.