supabase-flutter icon indicating copy to clipboard operation
supabase-flutter copied to clipboard

Error: GotrueError(message: Invalid Refresh Token, statusCode: 400)

Open ghost opened this issue 2 years ago • 8 comments

dependencies: supabase_flutter: ^1.0.0-dev.3

When token expired, Supabase.initialize get error.

Flutter Web Bootstrap: Programmatic ***** Supabase init completed Instance of 'Supabase' Got object store box in database supabase_authentication. XMLHttpRequest error. ***** SupabaseDeepLinkingMixin startAuthObserver Error: Unexpected null value.

ghost avatar Aug 08 '22 12:08 ghost

Hi @raphache

Thanks for opening an issue. Would you be able to provide some code so that I can reproduce this issue?

dshukertjr avatar Aug 09 '22 07:08 dshukertjr

Hi, This happings when run only first time, in debug mode, at vscode. In this case I need remove browser cookie, and it works.

More info: Platform: Web

***** SupabaseAuthState handleDeeplink http://localhost:3000/#/ onReceivedAuthDeeplink uri: http://localhost:3000/#/ No access_token detected. GoTrueException(message: Invalid Refresh Token, statusCode: 400) Error: GoTrueException(message: Invalid Refresh Token, statusCode: 400)

ghost avatar Aug 15 '22 11:08 ghost

Hi, I don't know if you did anything, but now its working.

ghost avatar Aug 18 '22 12:08 ghost

I am also getting this error pretty often. For us, auth tokens are not persisting between builds or after the app is closed (if on device). Often I am seeing this error before receiving the OPs error:

flutter: **** onAuthStateChange: AuthChangeEvent.tokenRefreshed
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Concurrent modification during iteration: _LinkedHashMap len:66.
#0      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:619:9)
#1      GoTrueClient._notifyAllSubscribers (package:gotrue/src/gotrue_client.dart:505:25)
#2      GoTrueClient._callRefreshToken (package:gotrue/src/gotrue_client.dart:485:7)
<asynchronous suspension>

Whenever the magic link is used we also see some flavor of this:

flutter: Concurrent modification during iteration: _LinkedHashMap len:14.

We are using an email magic link for sign in. I can provide code if needed.

cspecter avatar Sep 08 '22 14:09 cspecter

Sorry for the late reply here. @cspecter it would be great if you could provide some code for us to be able to reproduce this.

dshukertjr avatar Sep 28 '22 03:09 dshukertjr

I am also getting this error. This error occurs because of bad token storage.

In my case, I am developing app for windows named App_1 using supabase, so it store auth token at C:\Users\{USER}\Documents\auth\supabase_authentication.hive. So if I switch to App_2, it will also try to find valid auth token from the same path, that is not valid for this app, that's why the error occurs.

topperspal avatar Mar 01 '23 10:03 topperspal

We have shipped an update that will hopefully make things better with this issue. If you could try out v2.5.0 of supabase_flutter and see if things are better, that would be great.

dshukertjr avatar Apr 09 '24 13:04 dshukertjr

@dshukertjr hello, pasting this also here coz seems related. Wrote also to support. As mentioned, with users being kicked off, we cannot ship our product. Please LMK if/how we can help further with this. It would be also helpful if a workaround could be provided until a final fix is made, we suggested one but anything that lets client recover from login exceptions would be appreciated. https://github.com/supabase/supabase-flutter/issues/930

iosephmagno avatar Sep 04 '24 06:09 iosephmagno