Firebase Google users not showing in Firebase Console Authentication

Viewed 5870

Using Firebase Google Auth, when a user logs in successfully with their google account, they are not showing on our Firebase Console Authentication->Users screen. Only email/password users are showing up there.

Is there something extra that needs to be done to see the Google Auth users?

3 Answers

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 !!

Related