firestore:PERMISSION_DENIED:缺少权限或权限不足

时间:2021-08-30 15:19:38

I am getting the Error

我收到了错误

gettingdocuments.com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.

gettingdocuments.com.google.firebase.firestore.FirebaseFirestoreException:PERMISSION_DENIED:权限丢失或不足。

for the below code on else statement

对于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());
                 }
             }
         });

3 个解决方案

#1


30  

It simply works for me.

它对我有用。

Go in Database -> Rules ->

进入数据库 - >规则 - >

Change allow read, write: if false; to true;

更改允许读,写:如果为false;为真;

#2


2  

make sure your DB is not empty nor your query is for collection whom not exist

确保您的数据库不为空,您的查询不适用于不存在的收集

#3


2  

Go in Database -> Rules -> and do this

进入数据库 - >规则 - >并执行此操作

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}

#1


30  

It simply works for me.

它对我有用。

Go in Database -> Rules ->

进入数据库 - >规则 - >

Change allow read, write: if false; to true;

更改允许读,写:如果为false;为真;

#2


2  

make sure your DB is not empty nor your query is for collection whom not exist

确保您的数据库不为空,您的查询不适用于不存在的收集

#3


2  

Go in Database -> Rules -> and do this

进入数据库 - >规则 - >并执行此操作

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}