Prepare for the PgBouncer and IPv4 deprecations on 26th January 2024

Dart Reference v2.0

Sign in with ID Token

Allows you to perform native Google and Apple sign in by combining it with google_sign_in or sign_in_with_apple packages.


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

/// Web Client ID that you registered with Google Cloud.
/// This will be used to perform Google sign in on Android.
const webClientId = 'my-web.apps.googleusercontent.com';

/// iOS Client ID that you registered with Google Cloud.
const iosClientId = 'my-ios.apps.googleusercontent.com';

final GoogleSignIn googleSignIn = GoogleSignIn(
  clientId: iosClientId,
  serverClientId: webClientId,
);
final googleUser = await googleSignIn.signIn();
final googleAuth = await googleUser!.authentication;
final accessToken = googleAuth.accessToken;
final idToken = googleAuth.idToken;

if (accessToken == null) {
  throw 'No Access Token found.';
}
if (idToken == null) {
  throw 'No ID Token found.';
}

final response = await supabase.auth.signInWithIdToken(
  provider: OAuthProvider.google,
  idToken: idToken,
  accessToken: accessToken,
);