@@ -136,6 +136,8 @@ Once you have registered your app and created the client IDs, add the web client
136136
137137At this point you can perform native Google sign in using the following code. Be sure to replace the ` webClientId ` and ` iosClientId ` with your own.
138138
139+ The following example is very basic. Please refer to the [ google_sign_in] ( https://pub.dev/packages/google_sign_in ) package for the correct details.
140+
139141``` dart
140142import 'package:google_sign_in/google_sign_in.dart';
141143import 'package:supabase_flutter/supabase_flutter.dart';
@@ -156,18 +158,19 @@ Future<AuthResponse> _googleSignIn() async {
156158 // Google sign in on Android will work without providing the Android
157159 // Client ID registered on Google Cloud.
158160
159- final GoogleSignIn googleSignIn = GoogleSignIn(
160- clientId: iosClientId,
161- serverClientId: webClientId,
162- );
163- final googleUser = await googleSignIn.signIn();
164- final googleAuth = await googleUser!.authentication;
165- final accessToken = googleAuth.accessToken;
166- final idToken = googleAuth.idToken;
161+ final GoogleSignIn signIn = GoogleSignIn.instance;
162+
163+ // At the start of your app, initialize the GoogleSignIn instance
164+ unawaited(
165+ signIn.initialize(clientId: iosClientId, serverClientId: webClientId));
166+
167+ // Perform the sign in
168+ final googleAccount = await signIn.authenticate();
169+ final googleAuthorization = await googleAccount.authorizationClient.authorizationForScopes([]);
170+ final googleAuthentication = googleAccount!.authentication;
171+ final idToken = googleAuthentication.idToken;
172+ final accessToken = googleAuthorization.accessToken;
167173
168- if (accessToken == null) {
169- throw 'No Access Token found.';
170- }
171174 if (idToken == null) {
172175 throw 'No ID Token found.';
173176 }
0 commit comments