如何在 Firebase 中检索其他用户的信息,如电子邮件和显示名称?

Xi *_*iao 3 firebase firebase-authentication firebase-realtime-database

users在 Firebase 中有一个节点,用于存储每个用户的信息,但不包括 displayName andfirebase auth 数据库中的 email`。

有一天,我意识到我也需要用户displayNameemail信息。例如,在另一个用户创建的页面中,我想显示该用户的 displayName 和电子邮件。

鉴于

  1. displayName并且email不存储在users节点下,
  2. 用户的 uniqueId 已知

是否可以从 firebase auth 数据库(普通用户或管理员)检索用户的displayNameemail?或者我应该为已经在 firebase 中创建的用户做什么?

感谢:D

cre*_*not 5

有了 AdminSDK,就可以像这里解释的那样。

在文档中有每种方法的示例,但在你的情况下,我猜你搜索了这个

admin.auth().getUser(uid)
    .then(function(userRecord) {
        // See the UserRecord reference doc for the contents of userRecord.
        console.log("Successfully fetched user data:", userRecord.toJSON());
    })
    .catch(function(error) {
        console.log("Error fetching user data:", error);
    });
Run Code Online (Sandbox Code Playgroud)

你可以做类似的事情userRecord.displayName。完整的界面在这里