I am unable to to sucessfully to do , I followed the following steps as instructed on Firebase Docs:
Auth.signInWith
methods.(my case: i want to link email & password and Google OAUth). So this is the step i'm unclear about, I created a new provider using var provider = new firebase.auth.GoogleAuthProvider();
and I did not do Firebase.auth().signInWithPopup(provider)
. var credential = firebase.auth.GoogleAuthProvider.credential(
googleUser.getAuthResponse().id_token);
(I get an undefined googleUser error) this error seems appropriate since I have not signed in using Google Oauth but thats what the 2nd steps states(not to signin) auth.currentUser.link(credential)
My understanding is that currentUser needs to be linked to my existing Provider(Facebook). It seems that credential variable for google is never computed. Anyone with a functional code example would really help.
You can allow users to sign in to your app using multiple authentication providers by linking auth provider credentials to an existing user account. Users are identifiable by the same Firebase user ID regardless of the authentication provider they used to sign in.
Enable authentication for your Firebase project to use Firestore: In the Firebase console, click Authentication from the navigation panel. Go to the Sign-in Method tab. Enable Email/Password and Google authentication.
If you want to manually link a google and email/pass account to existing facebook only firebase user, you can do the following: First, the user should be signed in to Facebook. Link the google user:
var provider = new firebase.auth.GoogleAuthProvider();
auth.currentUser.linkWithPopup(provider);
Then link the email/pass account:
auth.currentUser.linkWithCredential(firebase.auth.EmailAuthProvider.credential(auth.currentUser.email, 'password'))
All these accounts to be linked must be new and not already linked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With