firestore:PERMISSION_DENIED:权限缺失或不足 [英] firestore: PERMISSION_DENIED: Missing or insufficient permissions
问题描述
我收到错误
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;
注意:这是用于开发目的的快速解决方案,因为它会关闭所有安全性.因此,不建议将其用于生产.
Note: It's quick solution for development purpose only because it will turns off all the security. So, it's not recommended for production.
用于生产:
如果从 firebase 进行身份验证:更改允许读取,写入:if
false; 到 request.auth != null;
If authenticated from firebase: Change allow read, write: if
false; to request.auth != null;
这篇关于firestore:PERMISSION_DENIED:权限缺失或不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!