supabase / supabase-flutter

Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.
https://supabase.com/
MIT License
662 stars 155 forks source link

ID token is null on web #835

Closed muezz closed 4 months ago

muezz commented 4 months ago

Describe the bug ID token is null after calling signIn() from google_sign_in which means that I am not able to use the method signInWithIdToken() from supabase_flutter.

To Reproduce Steps to reproduce the behavior:

  1. Set up google as your provider (set up the oauth client in GCP and then provide the client id and secret in the supabase dashboard)
  2. In a flutter web project, run the following snippet:

    final googleSignIn = GoogleSignIn(
      scopes: [
        'email',
      ],
    );
    final signInAccount = await googleSignIn.signIn();
    log(googleSignIn.currentUser.toString());
    
    if (signInAccount == null) throw 'Something went wrong!';
    final googleAuth = await signInAccount.authentication;
    log(googleAuth.accessToken.toString());
    log(googleAuth.idToken.toString());

    Check the debug console and you will notice that the ID token is logged out as null. This only happens on web.

Expected behavior As in iOS and android, I should get the ID token.

Version (please complete the following information): ├── supabase_flutter 2.3.3 │ ├── supabase 2.0.7 │ │ ├── functions_client 2.0.0 │ │ ├── gotrue 2.5.0 │ │ ├── postgrest 2.1.0 │ │ ├── realtime_client 2.0.0 │ │ ├── storage_client 2.0.1

Additional context I have done some research and it appears that this is expected behaviour on web. Please check out the google_sign_in and google_sign_in_web package page in pub.dev. It clearly says that due to the migration to the new GIS SDK, ID token will always be null. The confusion, however, is that my project's google auth worked flawlessly with Firebase. I only encountered this issue after I tried moving to Supabase.

dshukertjr commented 4 months ago

To perform OAuth sign-in on Web, you can use the .signInWithOAuth() method!

await supabase.auth.signInWithOAuth(Provider.google);