我得到了错误

gettingdocuments.com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED:缺少或权限不足。

对于下面关于else语句的代码

db.collection("users")
    .get()
    .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
        @Override
        public void onComplete(@NonNull Task<QuerySnapshot> task) {
             if (task.isSuccessful()) {
                 for (DocumentSnapshot document : task.getResult()) {
                     s(document.getId() + " => " + document.getData());
                 }
             } else {
                 s("Error getting documents."+ task.getException());
             }
         }
     });

当前回答

我有这个错误与Firebase管理员,解决方案是配置Firebase管理员正确遵循这个链接

其他回答

https://console.firebase.google.com

开发->数据库->规则->设置读、写-> true

对我来说,问题是AppCheck在我的Firestore控制台也被激活了。 所以我必须按照指南中所述的应用程序检查颤振指南

https://firebase.google.com/docs/app-check/flutter/debug-provider?hl=it&authuser=0

打开androidDebugProvider: true,从控制台复制调试令牌,并将其粘贴到Firestore部分(AppCheck—> app—> add调试令牌),它立即工作。

转到Apple Certificates, Identifiers & Profiles: 选择您的密钥上传firebase并进行检查: 访问DeviceCheck和apptest api以获取您关联的数据

在这里输入图像描述

此时,即2020年6月,默认情况下firebase是按时间定义的。 为满足自己的需要而安排好时间。

allow read, write: if request.time < timestamp.date(2020, 7, 10);

请注意:你的数据库仍然对任何人开放。我建议,请阅读文档并以对您有用的方式配置DB。

进入firebase控制台=>云firestore数据库,添加允许用户读写的规则。

=>允许读写