Skip to content

Commit 363d860

Browse files
committed
docs: Update Google signInWithGoogle method to match 7.xx API
1 parent bf0d25f commit 363d860

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

docs/auth/federated-auth.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,13 @@ Ensure the "Google" sign-in provider is enabled on the [Firebase Console](https:
3737
3838
Future<UserCredential> signInWithGoogle() async {
3939
// Trigger the authentication flow
40-
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
40+
final GoogleSignInAccount? googleUser = await GoogleSignIn.instance.authenticate();
4141
4242
// Obtain the auth details from the request
43-
final GoogleSignInAuthentication? googleAuth = await googleUser?.authentication;
43+
final GoogleSignInAuthentication googleAuth = googleUser.authentication;
4444
4545
// Create a new credential
46-
final credential = GoogleAuthProvider.credential(
47-
accessToken: googleAuth?.accessToken,
48-
idToken: googleAuth?.idToken,
49-
);
46+
final credential = GoogleAuthProvider.credential(idToken: googleAuth.idToken);
5047
5148
// Once signed in, return the UserCredential
5249
return await FirebaseAuth.instance.signInWithCredential(credential);

0 commit comments

Comments
 (0)