Skip to content

Commit 577436e

Browse files
authored
1 parent 4d23f7c commit 577436e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

google_signin/lib/main.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ class AppState extends State<App> {
4141
FirebaseAuth _auth = FirebaseAuth.instance;
4242
try {
4343
googleSignIn = GoogleSignIn();
44-
GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
45-
GoogleSignInAuthentication gauth =
46-
await googleSignInAccount.authentication;
47-
FirebaseUser user = await _auth.signInWithGoogle(
48-
accessToken: gauth.accessToken,
49-
idToken: gauth.idToken,
44+
GoogleSignInAccount googleUser = await googleSignIn.signIn();
45+
final GoogleSignInAuthentication googleAuth =
46+
await googleUser.authentication;
47+
final AuthCredential credential = GoogleAuthProvider.getCredential(
48+
accessToken: googleAuth.accessToken,
49+
idToken: googleAuth.idToken,
5050
);
51+
final AuthResult authRes = await _auth.signInWithCredential(credential);
52+
final FirebaseUser user = authRes.user;
5153

5254
setState(() {
5355
_username = user.displayName;

0 commit comments

Comments
 (0)