autoRefreshToken doesn't work
See original GitHub issueBug report
Describe the bug
After initialising supabase client with
createClient(supabaseUrl, supabaseKey, {
localStorage: AsyncStorage as any,
autoRefreshToken: true
});
and setting the JWT expiry to 60 (seconds) on the supabase dashboard, the token does not refresh after 60 seconds have elapsed. Oddly enough, setting the JWT expiry to anything less than 60 triggers the token refresh but it constantly updates without waiting for expiry
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Setup RN project (I used expo bare)
- Set JWT expiry to 60
- Add supabase auth state listener
- Sign in
- Wait for refresh token to update (doesn’t update)
Expected behavior
The token should refresh after the expiry time set on the supabase dashboard
System information
- OS: macOS
- Version of supabase-js: 1.11.14
- Version of Node.js: 16.1.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
What Are Refresh Tokens and How to Use Them Securely
Refresh tokens are bearer tokens. It's impossible for the authorization server to know who is legitimate or malicious when receiving a new ...
Read more >Solved: When to refresh an access token? - 391930
Solved: Hi all, According to the docs, An access token, if not used, will expire in 24 hours. In addition, according to information...
Read more >Should access tokens be refreshed automatically or manually?
Automatically Refreshing For every request that requires authentication/authorization, the user will send both tokens on the request headers. ...
Read more >Automatic refresh of Access Token doesn't work
I am "emedding for organization" and trying to use the automatic refresh of access token described here by providing eventHooks.
Read more >OAuth 2.0 Refresh Token Best Practices - Fusebit
Learn the best practices you should consider for managing OAuth 2.0 refresh tokens and access to your app.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry to dig out an old issue, but are we sure this is fixed? Despite initializing the Supabase client with
autoRefreshToken: true
I have to double checksession.expires_at
and initiatesupabase.auth.refreshSession()
manually throughout my app. (on version 1.28.2)There isn’t much documentation on how
autoRefreshToken
is supposed to work. But judging from the questions in the discussions section, I’m not the only one who is having trouble letting Supabase refresh expired JWTs.Having the same issue here. I’m constantly needing to log back into my app, even though I’ve set the expiration date to be a week long and have
autoRefreshToken
set to true. It seems like I need to re-enter my credentials even if the token is not actually expired (i.e. I need to re-enter my credentials even though a week has not passed since the last time I did it). This happens both on localhost and on my production website.If
autoRefreshToken
is true, I would expect the token to be automatically refreshed without needing to enter my credentials again. In other words, if I’ve logged in once, I should stay logged in unless I’ve explicitly logged out or cleared my cookies/cache.