【问题标题】:FirebaseException ([cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.)FirebaseException ([cloud_firestore/permission-denied] 调用者没有执行指定操作的权限。)
【发布时间】:2021-07-25 03:08:06
【问题描述】:

发生了异常。 FirebaseException([cloud_firestore/permission-denied]调用者没有执行指定操作的权限。)

代码:

  Future<Users> bringUser(id) async {
    DocumentSnapshot doc =
        await _firestore.collection("kullanicilar").doc(id).get();
    if (doc.exists) {
      Users users = Users.dokumandanUret(doc);
      return users;
    }
    return null;
  }

火力基地:

{
  "rules": {
    ".read": true, 
    ".write": true  
  }
}

【问题讨论】:

    标签: firebase flutter google-cloud-firestore


    【解决方案1】:

    您正在混淆 Realtime DatabaseFirestore 的安全规则,这是 Firebase 提供的两种不同的 NoSQL 数据库服务。

    您在问题中显示的规则适用于实时数据库,但在 Flutter 代码中您查询的是 Firestore。

    您需要在控制台的 Firestore 部分设置规则。

    它们看起来像:

    service cloud.firestore {
      match /databases/{database}/documents {
    
        // Match any document in the 'cities' collection
        match /cities/{city} {
          allow read: if <condition>;
          allow write: if <condition>;
        }
      }
    }
    

    (来自doc 的示例)

    【讨论】:

      猜你喜欢
      • 2021-08-09
      • 2022-08-06
      • 2021-09-17
      • 2022-08-03
      • 2021-12-26
      • 2021-05-20
      • 1970-01-01
      • 1970-01-01
      • 2020-07-13
      相关资源
      最近更新 更多