RukshanJS
RukshanJS

Reputation: 966

Why Both Web and Android Client IDs needed for Google authn using Supabase on Flutter?

My question is for educational purposes because I got the thing working, but wanted to know why and how.

I wanted to setup Google Authentication (Authn) using Supabase for my Flutter app. Following This Tutorial, I was able to get the Sign in with Google working with my Flutter app, but for that I needed to setup,

For my dev flavor app

  1. A GCP project myapp-gcp-dev
  2. Consent screen on GCP Credentials with auth domain 1 supabase_project_name.supabase.co
  3. Web Client ID and Client Secret with Auth direct URL https://supabase_project_name.supabase.co/auth/v1/callback
  4. Android Client ID with package name com.myteam.myapp.dev and SHA1 ..... for dev flavor

My questions,

Future<AuthResponse> _googleSignIn() async {
    /// TODO: update the Web client ID with your own.
    ///
    /// Web Client ID that you registered with Google Cloud.
    const webClientId = 'my-web.apps.googleusercontent.com';

    /// TODO: update the iOS client ID with your own.
    ///
    /// iOS Client ID that you registered with Google Cloud.
    const iosClientId = 'my-ios.apps.googleusercontent.com';

    // Google sign in on Android will work without providing the Android
    // Client ID registered on Google Cloud.

    final GoogleSignIn googleSignIn = GoogleSignIn(
      clientId: iosClientId,
      serverClientId: webClientId,
    );

Upvotes: 1

Views: 825

Answers (1)

dshukertjr
dshukertjr

Reputation: 18680

Google designed its OAuth authentication to require both the Android client ID and the web client ID for performing Google sign-in on Android. I do agree that it's counter intuitive to require the web client ID for OAuth on Android, but it's how Google implemented it, and there is nothing we can do about it as a user using it.

Upvotes: 4

Related Questions