mercredi 17 février 2021

How to link google account on Flutter Web?

I am trying to link anonymous account with google account but when I call the code, It create a new user and does not link accounts. How can I get credential without create an account on Flutter Web? I am taking "this credential is already associated with a different user account flutter" error.

  AuthCredential credentialG;

  if (kIsWeb) {
  GoogleAuthProvider googleProvider = GoogleAuthProvider();

  googleProvider
      .addScope('https://www.googleapis.com/auth/contacts.readonly');
  googleProvider.setCustomParameters({'login_hint': 'user@example.com'});

  credentialG =
      (await FirebaseAuth.instance.signInWithPopup(googleProvider))
          .credential;
}


 UserCredential credential =
    await user.linkWithCredential(credentialG).catchError((error) {
  errorEx = error;
  print(error);
});



Aucun commentaire:

Enregistrer un commentaire