Firestore Admin创建一个匿名用户 [英] Firestore Admin Create an anonymous user
问题描述
尝试使用admin创建匿名用户(我使用云功能),但我不知道是否可能:
admin.auth().createUser({电子邮件:userEmail,emailVerified:否,密码:userPassword,禁用:错误,匿名:true}).then(function(userRecord){console.log("util =" + util.inspect(userRecord))console.log("user recotd =" + userRecord.anonymous)}).catch(function(error){console.error(创建新用户时出错:",错误);});
在管理部分的文档中,没有匿名用户"部分.
在您的代码中,
Trying to create an anonymous user using admin (i use cloud functions) but i have no idea if it possible or not:
admin.auth().createUser({
email: userEmail,
emailVerified: false,
password: userPassword,
disabled: false,
anonymous: true
})
.then(function(userRecord) {
console.log("util = " + util.inspect(userRecord))
console.log("user recotd = " + userRecord.anonymous)
})
.catch(function(error) {
console.error("Error creating new user:", error);
});
On the documentation in the admin section there is no "Anonymous user" part.
https://firebase.google.com/docs/auth/admin/
Any idea if it possible or not ?
Thanks !
To create an anonymous Firebase user account using the Firebase Admin SDK, be sure that the Anonymous
sign-in provider is enabled in the Firebase console > Your Project > Authentication > Sign-in method
In your code, after you have initialized the SDK, call createUser(properties: CreateRequest): Promise with no arguments.
admin.auth().createUser({})
.then(function(userRecord) {
console.log('Successfully created new anonymous user:', userRecord.uid);
})
.catch(function(error) {
console.log('Error creating new anonymous user:', error);
});
If you check the Firebase console > Your Project > Authentication > Users
, the new Anonymous user will be listed.
这篇关于Firestore Admin创建一个匿名用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!