如何从uid获取FirebaseUser? [英] How to get FirebaseUser from a uid?

查看:43
本文介绍了如何从uid获取FirebaseUser?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个用户ID

Let's say I've a user id

String uid = "1234abcdefgh890";

现在,我想使用此uid获取一个 FirebaseUser ,我该怎么做?

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 

那我该如何获取 FirebaseUser ?

推荐答案

Firebase客户端SDK中没有API可以基于UID获取用户信息,因为这可能是安全问题.

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.

如果您需要此信息,则可以实施使用Firebase Admin SDK(具有具有此功能)的自己的服务器,也可以将用户信息存储在辅助数据库中,例如Firebase自己的实时数据库或Cloud Firestore.然后,您可以从应用程序的其余部分查询该数据库,并使用数据库的服务器端安全规则来安全访问以满足您的需求.

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.

另请参阅:

这篇关于如何从uid获取FirebaseUser?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆