问题
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