我目前正在使用 Pyrebase 包装器来获取所有用户的信息(例如他们的电子邮件和创建日期)。我尝试查看文档并将其交叉引用到 Pyrebase 文档,但我似乎没有得到我想要的东西。目前我已经尝试过这个:
import pyrebase
config={all required information, including path to service account .json file}
firebase=pyrebase.initialize_app(config)
db=firebase.database()
auth=firebase.auth()
extract_user = db.child('users').child('userId').get()
for x in extract_user.each():
print(x.val())
auth.get_account_info(user[x.val()])
但是我仍然失败了,我知道我错过了一些东西,但我不确定是什么。
注意:我将用户 userID 保存在数据库的 userId 下。所以我循环遍历了“get_account_info”中使用的每个 ID
有什么建议或方法可以完成这件事吗?
最佳答案
from firebase_admin import credentials
from firebase_admin import auth
cred = credentials.Certificate("./key.json")
initialize_app(cred, {'databaseURL' : "your database..."})
page = auth.list_users()
while page:
for user in page.users:
print("user: ", user.uid)
page = page.get_next_page()
然后,在您获得类似于“F5aQ0kAe41eV2beoasfhaksfjh2323alskjal”的用户 ID 后,您可以通过以下方式查看实际的电子邮件:
user = auth.get_user("F5aQ0kAe41eV2beoasfhaksfjh2323alskjal")
print("user email: ", user.email)
关于python - 列出 Firebase 身份验证中的所有用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65531711/