auth-helpers icon indicating copy to clipboard operation
auth-helpers copied to clipboard

NextJS - Invalid Refresh Token

Open ARMATAV opened this issue 3 years ago • 11 comments

On the latest release, using purely the example in examples/nextjs, after the exp time elapses, I'm getting the following error.

image

How can I make sure that the automatic token refresh fires off properly?

(Local development via supabase start and its associated container(s))

ARMATAV avatar Jul 12 '22 03:07 ARMATAV

Scratch that, this is with any and every example using NextJS and Supabase, with or without auth-helper. Very weird behavior.

ARMATAV avatar Jul 12 '22 07:07 ARMATAV

@ARMATAV Do you know if there has been any updates about this?

codewriter73 avatar Jul 15 '22 17:07 codewriter73

@ARMATAV Do you know if there has been any updates about this?

None so far - just a bunch of closed issues surrounding it; perhaps they deprioritized in favor of something else.

ARMATAV avatar Jul 16 '22 01:07 ARMATAV

Facing a similar issue where the users get signed out after the expiry time, upon debugging seems the refresh token fails with the Invalid Refresh token in logger.

krtkeyan avatar Jul 30 '22 04:07 krtkeyan

This seems to be in a recent update. Im lowered my auth-helpers-nextjs to 0.2.1 from 0.2.5 and this worked as expected

travispamaral avatar Aug 08 '22 20:08 travispamaral

Tried downgrading to 0.2.1, and even though I didn't get Invalid Refresh Token error message, still the token doesn't get refreshed and it logs JWT expired

krtkeyan avatar Aug 09 '22 04:08 krtkeyan

Any solution to this yet?

Bladeyy avatar Aug 10 '22 17:08 Bladeyy

I'm guessing does not work with supabase-js@next (1.36.0-next.17)?

mrolafsson avatar Aug 11 '22 15:08 mrolafsson

https://supabase.com/blog/supabase-js-v2

This solves the “getting logged out” issue, which has been a recurring challenge in our GitHub Discussions.

Should be good to go here now, right?

ARMATAV avatar Aug 16 '22 23:08 ARMATAV

I've seen @thorwebdev reference #92 as resolving this issue but it still seems to be present.

I'm using supabaseServerClient on an unsecured /api endpoint, and every now and then I get the error JWT expired unless I hit a client-side route which refreshes the token.

I've tried with @latest and @rc of supabase-js and related packages:

"@supabase/auth-helpers-nextjs": "^0.2.7",
"@supabase/auth-helpers-shared": "^0.1.3",
"@supabase/supabase-js": "^2.0.0-rc.8",

Edit: Updated package versions to reflect latest attempt state.

tourbillonlabs avatar Sep 03 '22 17:09 tourbillonlabs

The next release should make this more robust. You can already try it out with installing npm install @supabase/auth-helpers-nextjs@next and you can find the migration guide here: https://github.com/supabase/auth-helpers/blob/next/packages/nextjs/MIGRATION_GUIDE.md#migrating-to-03x

thorwebdev avatar Sep 28 '22 07:09 thorwebdev