Angie
Angie

Reputation: 107

How can I get a single user's data from Firebase Auth REST API by email only, not by idToken

It seems based on these Firebase Auth docs https://firebase.google.com/docs/reference/rest/auth/#section-get-account-info that the only way to get user data via the Firebase Auth REST API is by using this route https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=[API_KEY] and sending over the idToken (as well as the account API_KEY in the POST params). However what I need is the ability to obtain user data by sending an email address, and not an idToken (in addition to the account API_KEY in the POST params of course).

Is this listed in the docs elsewhere that I'm not seeing? I don't want to authenticate the user I'm referencing by email address, I just want the user's info (and I am authenticating via my account API_KEY and I would think that should be sufficient, no?

Upvotes: 1

Views: 1643

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317758

Seems like you will have to sign in first, passing returnSecureToken=true, get the ID token from the response, then lookup the account from there. There is apparently no documented API for performing a lookup with email.

Or, you could use the Firebase Admin SDK to look up the user using getUserByEmail().

Upvotes: 0

Related Questions