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

查看:38
本文介绍了如何从 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 呢?

How can I get the FirebaseUser then?

推荐答案

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天全站免登陆