In my project I need to link an existing email account whithout the user signed in. I have the user's email, so I'm trying this code:
firebase.auth().getUserByEmail(useremail);
on the client side.
But it gives me the firebase.auth(...).getUserByEmail is not a function error.
Does anyone know how to get the user by email address on the client side so I can link the accounts, the existing one and the providers?
Thanks in advance.
Using sdk 17.4.5
In my project I need to link an existing email account whithout the user signed in. I have the user's email, so I'm trying this code:
firebase.auth().getUserByEmail(useremail);
on the client side.
But it gives me the firebase.auth(...).getUserByEmail is not a function error.
Does anyone know how to get the user by email address on the client side so I can link the accounts, the existing one and the providers?
Thanks in advance.
Using sdk 17.4.5
Share asked May 22, 2020 at 15:12 lrentelrente 1,1401 gold badge10 silver badges30 bronze badges 1- I think the getUserByEmail method is only available for the Firebase Admin SDK. You might want to use some kind of server (or cloud function) so you could use the Firebase Admin SDK to fetch the user by E-mail. – Angel González Commented May 22, 2020 at 15:28
1 Answer
Reset to default 8For web clients, firebase.auth()
returns an Auth object. As you can see from the API documentation, there is no getUserByEmail method. on it. You're probably looking at the API documentation for Auth from the Firebase Admin SDK, which does not work on web clients. It only works on backends running nodejs.
If you want to use getUserByEmail
, you'll need to run it on a backend, and invoke that from your web client.
You should know that linking user accounts does actually require the use of this method. You link accounts after the user has signed in to both of them.