Hi, does the refresh token work correctly for anyo...
# help
s
Hi, does the refresh token work correctly for anyone? I'm running into this error https://github.com/supabase/supabase-js/issues/254#issuecomment-1090917141 whereby the refresh token is revoked immediately when it tries to refresh. (using supabase-auth-helpers)
n
Hello @sbr! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
🆕 Refresh token revoked immediately upon refresh attempt
s
@thorwebdev @garyaustin do you have an idea how to fix this?
g
I don't actually use auth-helpers, but was looking into more general refresh jwt issues on my own and looking at that code as part of that. I'm not familiar with the particular issue you point out, but if you go thru the issues and pull requests on auth-helpers you will see some of what is being looked at as far as token issues. I was more looking at apps going into background/sleep and losing the token and have some suggested work arounds in an issue, but those are not really directly auth-helpers related.
n
Refresh token revoked immediately upon refresh attempt
s
Thanks for your reply @garyaustin ! I don't think this is specific to auth-helpers as @abaum was facing the same issue in React Native as they mention here https://discord.com/channels/839993398554656828/932506573987790908/956126632853266472
Can you please point to some of the work arounds?
g
yeah, i just read the first one you posted and it could be related. My specific testing and "fix" is for the token expiring when the app is in background/sleep and then gotrue.js never refreshes it so all sb requests start failing. I had put it supabase/supabase as it involves several modules.. https://github.com/supabase/supabase/issues/6464 This particular bug is on the list of things they are trying to fix right now based on the work I've seen over the past week. BUT not sure it is the same as the one you have. In general though gotrue.js is not robust on missing a refresh cycle for any reason.
a
really glad to hear that the background refresh behavior is being looked into! as a workaround for that specifically we just have an appstate listener and manually refresh user on foreground. also was challenging to debug because behavior while connected to Xcode is different from the production build.
s
@abaum does the refresh token seem to work for you? Because as mentioned here https://github.com/supabase/supabase-js/issues/254#issuecomment-1090917141, the refresh token gets revoked immediately upon refresh for me
a
it does seem to work for me – and to be clearer, I just run
update({})
as documented here: https://github.com/supabase/gotrue-js/blob/master/src/GoTrueClient.ts#L351 prior to calling that, I'll see requests fail with "`JWT Expired` errors, and then after that call they go through successfully.