Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sirateek/27362e0c107559a20fdd409e63fd9b7e to your computer and use it in GitHub Desktop.
Save sirateek/27362e0c107559a20fdd409e63fd9b7e to your computer and use it in GitHub Desktop.
final GoogleSignIn googleSignIn = GoogleSignIn();
final FirebaseAuth _auth = FirebaseAuth.instance;
Future<FirebaseUser> signInWithGoogle() async {
final GoogleSignInAccount googleUser = await googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);
AuthResult authResult = await _auth.signInWithCredential(credential);
return authResult.user;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment