Flutter Supabase Google Auth, Step by Step

· 5 min read

Google sign-in is the most requested login option in most apps, and with Supabase it takes three systems working together: Google Cloud, the Supabase dashboard and your Flutter code. Each step is small. The trouble is that a mistake in any one shows up as a vague error in another.

This guide follows Supabase’s native Flutter flow for iOS and Android, step by step. It is part of our guide to building a Flutter app with Claude Code.

How the native flow works

Supabase explains it in one paragraph: “When the user provides consent, Google issues an identity token (commonly abbreviated as ID token) that is then sent to your project’s Supabase Auth server. When valid, a new user session is started by issuing an access and refresh token from Supabase Auth.”

So the google_sign_in package shows Google’s native sign-in sheet, you get an ID token, and you hand it to supabase.auth.signInWithIdToken. No browser redirect, no deep link.

On Flutter web, macOS, Windows and Linux, Supabase uses signInWithOAuth instead, which “will open a browser window to perform the sign in.” This guide covers the mobile path only.

Step 1: set up the Google Auth Platform

In Google Cloud, create or pick a project, then open the Google Auth Platform console. You configure:

  • Audience: which Google users may sign in.
  • Data Access (Scopes): Supabase needs openid (which you add manually), plus .../auth/userinfo.email and .../auth/userinfo.profile (added by default).
  • Branding: the name and logo on the consent screen.

Supabase warns that adding more scopes, “especially those on the sensitive or restricted list,” may trigger a verification that “may take a long time.” Keep to the three above unless you really need more.

Supabase also recommends a custom domain for your project. Without one, users see <project-id>.supabase.co, which “does not inspire trust.”

Step 2: create the client IDs

In the Clients section, create OAuth client IDs:

  1. Web application. The Flutter code passes this one as serverClientId. Keep its ID handy.
  2. Android. Provide the SHA-1 certificate fingerprint used to sign your app.
  3. iOS. Provide the bundle ID, and the App Store ID and Team ID if the app is already published.

The Android fingerprint is the step most people get wrong. Supabase notes: “You will have a different set of SHA-1 certificate fingerprints for testing locally and going to production. Make sure to add both to the Google Cloud Console, and add all of the Client IDs to the Supabase dashboard.” If you use Play App Signing, the production fingerprint is in Play Console, not in your local keystore. If you use flavors, each package name needs its own Android client.

Step 3: configure Supabase

In the Supabase dashboard, open Authentication, then Providers, then Google:

  • Enable the provider.
  • Add every client ID you created (Web, Android, iOS).
  • For iOS, enable “Skip nonce check.” Supabase’s docs explain why it matters: Supabase Auth “rejects the sign-in when the ID token has a nonce and signInWithIdToken doesn’t pass one, unless the Skip nonce check option is enabled.”

Step 4: add the iOS URL scheme

Google sign-in on iOS needs a URL type in ios/Runner/Info.plist. The value is the REVERSED_CLIENT_ID of your iOS client, in the form com.googleusercontent.apps.<id>:

<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>com.googleusercontent.apps.YOUR-IOS-CLIENT-ID</string>
    </array>
  </dict>
</array>

Step 5: the Flutter code

Add the packages:

flutter pub add google_sign_in supabase_flutter

Then the sign-in function, adapted from Supabase’s guide:

import 'package:google_sign_in/google_sign_in.dart';
import 'package:supabase_flutter/supabase_flutter.dart';

final supabase = Supabase.instance.client;

Future<void> signInWithGoogle() async {
  const webClientId = 'YOUR-WEB-CLIENT-ID.apps.googleusercontent.com';
  const iosClientId = 'YOUR-IOS-CLIENT-ID.apps.googleusercontent.com';
  final scopes = ['email', 'profile'];

  final googleSignIn = GoogleSignIn.instance;
  await googleSignIn.initialize(
    serverClientId: webClientId,
    clientId: iosClientId,
  );

  final googleUser = await googleSignIn.authenticate();

  final authorization =
      await googleUser.authorizationClient.authorizationForScopes(scopes) ??
      await googleUser.authorizationClient.authorizeScopes(scopes);

  final idToken = googleUser.authentication.idToken;
  if (idToken == null) {
    throw AuthException('No ID Token found.');
  }

  await supabase.auth.signInWithIdToken(
    provider: OAuthProvider.google,
    idToken: idToken,
    accessToken: authorization.accessToken,
  );
}

A few notes on the code:

  • GoogleSignIn.instance is a singleton, and initialize must run before other calls.
  • Supabase’s sample uses attemptLightweightAuthentication(), which returns null if it cannot sign in quietly. The guide mentions authenticate() as the alternative that “will return a GoogleSignInAccount or throw an exception.” Use the lightweight call on app start to restore a session silently, and authenticate() when the user taps the button.
  • Catch exceptions from authenticate() and treat a user-cancelled sign-in as a normal outcome, not an error.

Supabase must already be initialized with your project URL and publishable key before this runs; see the setup in Flutter Firebase vs Supabase.

Troubleshooting

When sign-in fails, check these in order. Each one maps to a step above.

  • Android works locally but not from Play. Is the Play App Signing SHA-1 registered as an Android client in Google Cloud, and is that client ID added in Supabase?
  • iOS fails at the Supabase step. Is Skip nonce check on, and is the iOS client ID registered in Supabase?
  • iOS fails before the Google sheet finishes. Does the CFBundleURLSchemes entry match the reversed iOS client ID exactly?
  • No ID token. Is serverClientId set to the Web client ID, not the Android or iOS one?

Before you ship

If you offer Google sign-in on iOS, read Apple’s rules on third-party login in our post on guideline 4.8 login services; many apps add Sign in with Apple alongside Google. Apple also requires that apps with account creation “offer account deletion within the app,” covered in the account deletion requirement. For the Firebase version of this flow, see Flutter Google sign-in.

MobileKit’s auth skill runs through the same client ID and fingerprint checklist, because those are where this flow breaks.

Sources read on the day this post was written: Supabase: Sign in with Google, Supabase Flutter quickstart and Apple App Review Guidelines.

Questions

Which Google client IDs does a Flutter app need for Supabase?

Supabase's guide uses a Web client ID as serverClientId and an iOS client ID as clientId, and you create an Android client ID with your SHA-1 fingerprint. Register all of them on the Google provider page in the Supabase dashboard.

Why does Google sign-in fail on iOS with a nonce error?

Supabase's Flutter instructions say to enable the Skip nonce check option on the Google provider page for iOS. Supabase Auth rejects a sign-in when the ID token has a nonce that signInWithIdToken does not pass, unless that option is on.

Should I use signInWithOAuth or signInWithIdToken on mobile?

Supabase's guide uses the google_sign_in package and signInWithIdToken for native iOS and Android. It uses signInWithOAuth, which opens a browser window, for Flutter web, macOS, Windows and Linux.

Try it on your next idea

One payment, every update to this major version, and a refund window if it is not for you. Refund policy.