After the 0.7.0 update of firebase_auth I can no longer log in with Google. How do I proceed to log in with google+firebase?

Asked

Viewed 95 times

0

After the user used the Google login option he used this code, but after updating the firebase_auth for version 0.8.0+1 this code broke:

var fUser = await fAuth.linkWithGoogleCredential(
        idToken: userGoogleAuthentication.idToken,
        accessToken: userGoogleAuthentication.accessToken);

and returns the following error:

Error: The method 'linkWithGoogleCredential' isn't defined for the class 'FirebaseAuth'.
 - 'FirebaseAuth' is from 'package:firebase_auth/firebase_auth.dart'

I didn’t find in the github of lib how to do, there’s showing me exactly how I’m doing.

1 answer

0

After looking at the source code of the lib I saw that the method linkWithGoogleCredential was replaced by linkWithCredential who receives a AuthCredential lib provides some classes that return a AuthCredential.

Who are:

  • GoogleAuthProvider
  • FacebookAuthProvider
  • PhoneAuthProvider
  • EmailAuthProvider
  • GitHubAuthProvider
  • TwitterAuthProvider

Now with the change the code was like this:

import 'package:firebase_auth/firebase_auth.dart';

var fUser = await fAuth.linkWithCredential(GoogleAuthProvider.getCredential(
            idToken: userGoogleAuthentication.idToken,
            accessToken: userGoogleAuthentication.accessToken));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.