问题
https://firebase.google.com/docs/reference/security/database/#authtokenF
{
"rules": {
"c":{
".write":"newData.child('email').val()=== auth.token.email"
},
}
}
Always it showing "Simulated write denied"
How to solve this problem ? Is there any mistake with my firebase rule
回答1:
It looks like you're not providing an email address in the authentication data.
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:
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:
来源:https://stackoverflow.com/questions/49878527/firebase-rule-auth-token-email-is-not-working-simulated-write-denied