lrente
lrente

Reputation: 1130

firebase.auth(...).getUserByEmail is not a function

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

Upvotes: 6

Views: 7124

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317362

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

Upvotes: 8

Related Questions