Firebase规则auth.token.email无法正常工作:“模拟写入被拒绝" [英] Firebase rule auth.token.email is not working: "Simulated write denied"
问题描述
https://firebase.google.com/docs/reference/安全性/数据库/#authtokenF
{
"rules": {
"c":{
".write":"newData.child('email').val()=== auth.token.email"
},
}
}
始终显示模拟写入被拒绝"
如何解决这个问题呢 ?我的Firebase规则有什么错误
Always it showing "Simulated write denied"
How to solve this problem ? Is there any mistake with my firebase rule
推荐答案
您似乎没有在身份验证数据中提供电子邮件地址.
It looks like you're not providing an email address in the authentication data.
当您选择一个提供程序时,模拟器会显示它将使用的确切的auth.token
有效负载.对于Google
提供程序,我的Auth令牌有效负载如下:
When you select a provider, the simulator shows the exact auth.token
payload that it will use. For the Google
provider my Auth token payload looks like this:
模拟器使用此处显示的文字JSON,并将其用作auth.token
.
The simulator takes the literal JSON that is shown in here, and uses it as auth.token
.
{
"provider": "google",
"uid": "27e08474-4e33-460d-ba92-ba437c6aa962"
}
由于没有提供电子邮件,因此您的规则(正确)失败了.
Since there is no email provided, your rules (correctly) fail.
要测试此方案,您需要切换到自定义提供程序,以便可以使用电子邮件属性指定自己的身份验证令牌
For testing this scenario, you'll want to switch to a custom provider, so that you can specify your own auth token with an email property:
这篇关于Firebase规则auth.token.email无法正常工作:“模拟写入被拒绝"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!