How to get FirebaseUser from a uid?

我只是一个虾纸丫 提交于 2021-02-04 08:07:03

问题


Let's say I've a user id

String uid = "1234abcdefgh890";

Now, I'd want to get a FirebaseUser using this uid, how do I do that?

FirebaseAuth auth = FirebaseAuth.instance;
FirebaseUser user = (await auth.signInWithXXX(uid)).user; // is there any method like this 

How can I get the FirebaseUser then?


回答1:


There is no API in the Firebase client-side SDKs to get user information based on a UID, as this could potentially be a security concern.

If you need this information, you can either implement your own server that uses the Firebase Admin SDKs (which do have this functionality), or you can store user information in a secondary database, such as Firebase's own Realtime Database or Cloud Firestore. Then you can query this database from the rest of your application, and secure access to fit your needs with the database's server-side security rules.

Also see:

  • How do I return a list of users if I use the Firebase simple username & password authentication
  • Firebase get user by ID
  • How to get the user email in Firebase based on user id
  • Using Firebase User UID to retrieve profile info
  • Firebase get Authentication details using UID


来源:https://stackoverflow.com/questions/60413628/how-to-get-firebaseuser-from-a-uid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!