在我的flutter项目中测试firebase时,这些权限被拒绝了,我无法弄清楚。我使用的是电子邮件身份验证,因此无法正常工作。但是在其他帖子中读到关于此错误的信息后,我尝试允许在我的安全规则中全部允许read,write:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
但是我仍然遇到相同的错误:
W/RepoOperation(24227): setValue at /1_testing failed: DatabaseError: Permission denied
W/RepoOperation(24227): setValue at /2_testing failed: DatabaseError: Permission denied
E/flutter (24227): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(-3, Permission denied, , null)
我发送数据的代码是:
final databaseReference = FirebaseDatabase.instance.reference();
void createRecord(){
databaseReference.child("1_testing").set({
'title': 'It worked once',
'description': 'blablibla'
});
databaseReference.child("2_testing").set({
'title': 'it worked twice',
'description': 'blobloblo'
});
我还重新下载并同步了我的json文件 你有什么想法 ?这是我第一次尝试这样做,如果答案似乎显而易见,请提前对不起:/
答案 0 :(得分:1)
这些是Firestore的规则:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
在代码中,您正在使用实时数据库。您需要导航到控制台中的“实时数据库”选项卡,并将规则更新为以下内容:
{
// Allow read/write access to all users under any conditions
// Warning: **NEVER** use this ruleset in production; it allows
// anyone to overwrite your entire database.
"rules": {
".read": true
".write": true
}
}
在此处详细了解它:
https://firebase.google.com/docs/rules/insecure-rules#database