[英]How to get the user id of a email from firebase email authentication
I want to access the id (or uid ) of a email from firebase authentication .我想从 firebase authentication 访问电子邮件的 id (或 uid )。 Its not the id of current users id, so i cant use firebase.auth().currentUser.uid.
它不是当前用户 ID 的 ID,所以我不能使用 firebase.auth().currentUser.uid。 and i am also not in a position to store the uid in the database at the time of sign up and fetch it.
而且我也无法在注册时将 uid 存储在数据库中并获取它。 is the anyway to fetch it directly from firebase authentication system
无论如何直接从firebase身份验证系统获取它
The Firebase Admin SDK supports looking up user information with an email: Firebase Admin SDK 支持通过电子邮件查找用户信息:
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);
});
This method returns a UserRecord object for the user corresponding to the email provided.此方法为与提供的电子邮件对应的用户返回一个 UserRecord 对象。
If the provided email does not belong to an existing user or the user cannot be fetched for any other reason, the Admin SDK throws an error.如果提供的电子邮件不属于现有用户或由于任何其他原因无法获取用户,则 Admin SDK 会引发错误。
Reference: https://firebase.google.com/docs/auth/admin/manage-users参考: https : //firebase.google.com/docs/auth/admin/manage-users
使用 admin.auth().getUserByEmail(email)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.