javascript - 无论如何要从 Firebase 身份验证 wintout 登录中检索 uid
问题描述
是否有办法从 Firebase Authentication wintout 登录中检索 uid,只能使用注册时提供的电子邮件
解决方案
客户端 SDK 中没有通过用户电子邮件地址查找 UID 的功能。但该功能存在于 Firebase 的 Admin SDK 中。例如,在(服务器端)Node.js 中,您可以这样做:
admin.auth().getUserByEmail(email)
.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);
});
此功能仅在 Admin SDK 中的原因是它们将在受信任的环境中使用,并且对于在客户端中具有此功能的许多应用程序可能不需要。通过将 API 置于受信任的环境中,例如您的开发机器、您控制的服务器或 Cloud Functions,您可以在您的用例需要时将功能公开给您的应用程序。
或者,您可以将必要的信息存储在数据库中(例如 Firebase 的实时数据库或 Cloud Firestore),并允许用户从那里进行查找。
推荐阅读
- javascript - 如何在点击事件上触发 jQuery 函数,但仅在页面加载后?
- java - 如何通过 Weblogic Java API 检索 Weblogic 的 Deployment 测试点
- c++ - 加号运算符的 C++ 重载
- webpack - 如何让 Font Awesome 5 与 webpack 一起工作
- javascript - 使用jQuery将数据从一个表的选定行复制到另一个表
- c - mingw-w64 C版支持吗?
- excel - 逐行读取csv流,为Excel Range创建数组
- c# - 无法跟踪在 CustomControl WPF 中的列表中添加/删除项目
- r - 使用for循环变量访问数组中的元素在R中产生NA
- firebase - 在 Angular 6 中修改其他用户