Back to results for “Authentication”
Flutter › Firebase Authentication in Flutter

How do you properly implement Google sign in specifically within a Flutter app, and what additional setup steps beyond simply configuring Firebase itself does this particular sign in method actually require?

Intermediate

Answer

Implementing Google sign in requires both configuring the Google sign in method within the Firebase console itself and additionally integrating the separate google_sign_in Flutter package, which handles displaying the native Google account selection interface, and after a user successfully selects their Google account through that native interface, you then take the resulting Google authentication credential and use it to actually sign that same user into Firebase Authentication itself, properly linking their selected Google identity to a corresponding Firebase user account.
final googleUser = await GoogleSignIn().signIn();
final googleAuth = await googleUser!.authentication;
final credential = GoogleAuthProvider.credential(
  accessToken: googleAuth.accessToken,
  idToken: googleAuth.idToken,
);
await FirebaseAuth.instance.signInWithCredential(credential);
Real-world example A productivity app lets a user sign in instantly using their existing Google account rather than needing to create and remember an entirely separate new password, meaningfully reducing friction during the initial sign up process.

Common follow-ups: What platform specific configuration steps are required for Google sign in to work correctly on both Android and iOS?;How does account linking work if a user later wants to also add email and password login to their existing Google authenticated account?