Firebase Google users not showing in Firebase Console Authentication

As indicated by Frank, to fully sign into Firebase the call to signInWithCredential() was needed. After implementing this functionality, users signing in with Google showed up in the Firebase console.


In Flutter, besides GoogleSignIn, you also need to install firebase_auth package.

https://pub.dev/packages/firebase_auth#-installing-tab-

https://pub.dev/packages/firebase_auth

import 'package:firebase_auth/firebase_auth.dart';

final GoogleSignIn _googleSignIn = GoogleSignIn();
final FirebaseAuth _auth = FirebaseAuth.instance;

Future<FirebaseUser> _handleSignIn() async {
  final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
  final GoogleSignInAuthentication googleAuth = await googleUser.authentication;

  final AuthCredential credential = GoogleAuthProvider.getCredential(
    accessToken: googleAuth.accessToken,
    idToken: googleAuth.idToken,
  );

  final FirebaseUser user = (await _auth.signInWithCredential(credential)).user;
  print("signed in " + user.displayName);
  return user;
}

...

_handleSignIn()
    .then((FirebaseUser user) => print(user))
    .catchError((e) => print(e));

Follow the below steps:

  • Trigger the Google Authentication flow.

 

final GoogleSignInAccount googleUser = await GoogleSignIn().signIn();
  • Obtain the auth details from the request.

 

final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
  • Create a new credential

 

final GoogleAuthCredential googleCredential = GoogleAuthProvider.credential(
    accessToken: googleAuth.accessToken,
    idToken: googleAuth.idToken,
  );
  • Sign in to Firebase with the Google [UserCredential]

 

final UserCredential googleUserCredential =
    await FirebaseAuth.instance.signInWithCredential(googleCredential);

That's it !!