flutter_firebase icon indicating copy to clipboard operation
flutter_firebase copied to clipboard

signInWithGoogle method missing

Open jalakoo opened this issue 6 years ago • 2 comments

Got this compiler error from the loginpage.dart:

lib/loginpage.dart:110:57: Error: The method 'signInWithGoogle' isn't defined for the class 'firebase_auth::FirebaseAuth'.
Try correcting the name to the name of an existing method, or defining a method named 'signInWithGoogle'.
FirebaseAuth.instance.signInWithGoogle

Changing the code on line 109:

// From
FirebaseAuth.instance.signInWithGoogle(idToken: googleuser.idToken, accessToken: googleuser.accessToken).

// To
FirebaseAuth.instance.signInWithCustomToken(token: googleuser.idToken).

Allows the app to compile, but not sure if this the desired alternative and have yet to test on a device.

jalakoo avatar Feb 09 '19 17:02 jalakoo

Following the firebase_auth you should be using

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

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

Instead of:

FirebaseAuth.instance.signInWithGoogle(idToken: googleuser.idToken, accessToken: googleuser.accessToken).

ginuxone avatar May 04 '19 13:05 ginuxone

But now its again changed and the code will have an additional step, instead of the Firebase user, we get AuthResults, we have to extract the FirebaseUser from that

final AuthCredential credential = GoogleAuthProvider.getCredential( accessToken: googleAuth.accessToken, idToken: googleAuth.idToken, ); AuthResult authResults = await _auth.signInWithCredential(credential); FirebaseUser user = authResults.user;

Batzee avatar Apr 18 '20 01:04 Batzee