Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokens not getting auto-refreshed #32

Closed
awalias opened this issue Dec 17, 2020 · 19 comments
Closed

Tokens not getting auto-refreshed #32

awalias opened this issue Dec 17, 2020 · 19 comments
Assignees
Labels
bug Something isn't working

Comments

@awalias
Copy link
Member

awalias commented Dec 17, 2020

reported by Omar:

"encountering forced logouts after ~30 min - 1 hour (not sure how long exactly)"

@awalias awalias added the bug Something isn't working label Dec 17, 2020
@thorwebdev
Copy link
Member

@awalias that should have been fixed via #31

Are they maybe using an outdated version?

@SweeToxin
Copy link

@awalias Thank you for the issue
@thorwebdev Ant just updated our "boxes" I'm waiting to see if it wasn't due to that before I can confirm
Thank you both for your time

@thorwebdev
Copy link
Member

@SweeToxin the important thing is that you're using the latest version of supabase-js v.1.1.2

@awalias
Copy link
Member Author

awalias commented Dec 19, 2020

Confirmed supabase js is 1.1.2

@ykdojo
Copy link

ykdojo commented Jan 15, 2021

@awalias @kiwicopple is this issue still active?

@kiwicopple
Copy link
Member

Note from Omar

we encounter this when running locally. i.e. on localhost when a token expires it just logs you off
It seems from a cursory glance that token refreshing works fine on our deployed domains

I think in gotrue we need the ability to set multiple domain names where a token can be valid from (@awalias )

@kiwicopple
Copy link
Member

Also to be investigated: #54

@churichard
Copy link

churichard commented Mar 10, 2021

I'm also running into this issue, or something similar. Specifically, my network requests return a 401 error, saying that the jwt has expired. I'm running a Next.js app on localhost, following this example for authentication: https://github.com/supabase/supabase/tree/master/examples/nextjs-with-supabase-auth

I don't actually get logged out, my network requests just start failing after a certain period of time. If I refresh the page, then I am somehow authenticated again and my network requests work fine. But I would expect the jwt to be auto-refreshed once it is expired, without me reloading the page.

Update: This happens not just on localhost, but also on my deployed application on a real domain name. This is a pretty big blocker for me, as my app is designed to be long-running and shouldn't be silently failing network requests.

@dommarr
Copy link

dommarr commented Mar 11, 2021

I'm also running into this issue, or something similar. Specifically, my network requests return a 401 error, saying that the jwt has expired. I'm running a Next.js app on localhost, following this example for authentication: https://github.com/supabase/supabase/tree/master/examples/nextjs-with-supabase-auth

I don't actually get logged out, my network requests just start failing after a certain period of time. If I refresh the page, then I am somehow authenticated again and my network requests work fine. But I would expect the jwt to be auto-refreshed once it is expired, without me reloading the page.

+1 - same issue here

@awalias
Copy link
Member Author

awalias commented Apr 7, 2021

possibly related: #61

@akiarostami
Copy link

akiarostami commented Sep 16, 2021

@churichard, @dommarr did you fix this issue? I'm still seeing this problem, and it has made my app unusable. I would appreciate it if you could let us know the solution (if you fixed it).

@churichard
Copy link

@akiarostami I still run into issues with auth, albeit not the same one I ran into in the comment above. I think that one has been fixed.

If you're having issues, I'd recommend moving your authentication entirely client-side and not following the Next.js example (which uses SSR). The Next.js example didn't fully work last time I tried to do it; doing things client-side seems to work better.

@akiarostami
Copy link

Thanks @churichard for the quick reply.

There are some issues with moving the authentication fully to the client side as well. In that case, we won't be able to use Next.js's server side features and would have to do all authentication checks, data loading, etc. on the client side as well.

I'm currently doing some stuff client-side, but I'm still sporadically getting jwt expiration error when I call Supabase's methods. Don't you see any of that?

I hope the wonderful Supabase team pays some attention to this, as it makes the Next.js experience very unpleasant, if not unusable.

@churichard
Copy link

@akiarostami Sorry, I'm not running into any jwt expiration error issues. Maybe you could shoot them an email about it, or open a new issue.

@sjc5
Copy link

sjc5 commented Nov 5, 2021

I am experiencing this as well. Fully client side. JWT token expires if app tab is left open for a while, and everything rendered conditionally based on existence of the session disappears in my UI (of course). Upon refreshing the page, everything works again.

Wondering why this was closed if the issue persists? Is there a fix?

@silentworks
Copy link
Contributor

@sjc5 this issue was fixed from what I can remember.

@rutikwankhade
Copy link

I am also facing the same issue. Has anyone found a fix around this?

@silentworks
Copy link
Contributor

@rutikwankhade please open a new issue with the problem you are facing. Also outline how to replicate the problem in your new issue. This was fixed and this issue is closed.

@dthyresson
Copy link
Contributor

Hi @rutikwankhade I just posted and Issue here #201 that perhaps reproduces your case -- or adds some context.

TLDR; you can get into a state where a user has no more valid refresh tokens and then the client can no longer get a new access token -- even though it does try to refresh periodically.

If you see similar behavior, please add to the comments on that Issue to track. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests