13

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.

Jaime Gómez
  • 6,961
  • 3
  • 40
  • 41
rena
  • 1,223
  • 3
  • 17
  • 30
  • 1
    Give your JSON tree, and what have you tried. Also which language are you programming in – Dravidian Sep 17 '16 at 06:21
  • There is currently no method in Firebase Authentication to load a user by a UID. See http://stackoverflow.com/questions/37634039/firebase-android-load-user-by-uid, http://stackoverflow.com/questions/14673708/how-do-i-return-a-list-of-users-if-i-use-the-firebase-simple-username-password, http://stackoverflow.com/questions/28735377/where-does-firebase-save-its-simple-login-users and probably some more – Frank van Puffelen Sep 17 '16 at 14:41
  • @FrankvanPuffelen is this possible now? loading user by UID in firebase auth? I don't see it in the docs so I think the answer is no – Karen Jun 26 '20 at 02:59

1 Answers1

18

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

Community
  • 1
  • 1
Jaime Gómez
  • 6,961
  • 3
  • 40
  • 41