Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase get user by ID [duplicate]

Is there a way to get user information (like email, picture) based on its UID?

I mean not for the currently logged user, but any other user.

like image 545
rena Avatar asked Sep 17 '16 04:09

rena


1 Answers

If you're using the authentication methods provided by Firebase, then no, you can only get it from the current session/user, and if you need to query for it later then you need to save it in your own datastore.

Usually what I do is load the user data when authentication changes, if it's not there then I save a new object (using the uid as key), with whatever data is relevant for the application. If you're interested in the picture then you might need to update your data often.

You can find a more in depth explanation, with some actual samples, in the following question: Where does firebase save it's simple login users?.

like image 96
Hanuman Avatar answered Nov 16 '22 01:11

Hanuman