gpt4 book ai didi

firebase - 如何使用具有注册电子邮件的 Firebase 身份验证来模拟 Firebase 数据库规则

转载 作者:行者123 更新时间:2023-12-02 22:14:52 27 4
gpt4 key购买 nike

我是 Firebase 新手,我正在尝试 Firebase 数据库规则和 Firebase 身份验证。
我尝试使用 firebase 身份验证来执行 firebase 数据库规则。
因此,我创建了一封演示电子邮件来测试数据库规则。
电子邮件:abc@gmail.com
uid:WfipZwUuNvTIkRYvPxsFqzd1rag2
我的数据库规则(遵循firebase站点)https://firebase.google.com/docs/database/security/user-security
Firebase 数据库规则:

{
"rules": {
"users": {
"$user_id": {
// grants write access to the owner of this user account
// whose uid must exactly match the key ($user_id)
".write": "$user_id == auth.uid",
".read" : "$user_id == auth.uid"
}
}
}
}


我尝试将模拟器用于数据库规则,并使用以下自定义有效负载进行身份验证,但无法访问读取或写入。
有效负载:

{
"provider": "password",
"uid": "WfipZwUuNvTIkRYvPxsFqzd1rag2"
}


那么我在这一点上缺少什么呢?

更新
我需要的是使用 firebase 验证电子邮件来授予对数据库的读写访问权限。
我目前正在尝试使用 firebase 数据库规则模拟器。
我总是被拒绝访问。所以也许我的有效负载不适合身份验证。需要帮助!!!

最佳答案

我尝试了您在模拟器中指定的规则,并且允许模拟写入,唯一的区别是我没有使用您指定的 uid。结果见下图 enter image description here enter image description here

关于firebase - 如何使用具有注册电子邮件的 Firebase 身份验证来模拟 Firebase 数据库规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50840930/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com