firestore:PERMISSION_DENIED:缺少权限或权限不足
问题描述:
我遇到错误
gettingdocuments.com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED:缺少权限或权限不足.
gettingdocuments.com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
对于else语句中的以下代码
for the below code on else statement
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());
}
}
});
答
对我来说简单.
转到数据库-> 规则->
Go in Database -> Rules ->
将allow read, write: if
false; 更改为 true;
注意:这完全关闭了数据库的安全性!
不经身份验证即可将其写成世界可写!!!这不是建议在生产环境中使用的解决方案.仅将此用于测试目的.
Making it world writable without authentication!!! This is NOT a solution to recommend for a production environment. Only use this for testing purposes.