Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signInWithGoogle method missing #1

Open
jalakoo opened this issue Feb 9, 2019 · 2 comments
Open

signInWithGoogle method missing #1

jalakoo opened this issue Feb 9, 2019 · 2 comments

Comments

@jalakoo
Copy link

jalakoo commented Feb 9, 2019

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.

@ginuxone
Copy link

ginuxone commented May 4, 2019

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).

@Batzee
Copy link

Batzee commented Apr 18, 2020

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants