Firestore数据库Android中缺少权限或权限不足

时间:2019-09-07 12:24:30

标签: android firebase google-cloud-firestore firebase-security

我正在使用Firestore数据库。为此,我为所有文档的读/写设置了安全规则。但是,当我使用android中的 get 更新删除方法时,它会返回缺少权限或权限不足错误。 / p>

我在stackoverflow中读到,集合应该存在于数据库中。我也尝试过,但是没有用。 https://stackoverflow.com/a/47270946/7591349

安全规则:

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

从android端获取呼叫:

App.instance?.firestoreDB?.collection(DBConstant.COLLECTION_USER)
         ?.whereEqualTo(USER_PHONE_NUMBER, numberCode)
         ?.get()
         ?.addOnSuccessListener {}
         ?.addOnFailureListener { e -> }

firestore的响应:

Listen for Query(user where phoneNumber == +918888888885) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}

相同的代码和相同的安全规则在我的其他Firebase项目中起作用,但我无法弄清楚该项目出了什么问题。

====编辑===

Security Rules

Database Structure

0 个答案:

没有答案