【问题标题】:Firestore Permission Denied in Android on Test RulesAndroid 中的 Firestore 权限在测试规则上被拒绝
【发布时间】:2020-12-12 01:26:56
【问题描述】:

我是第一次使用firestore,遇到权限被拒绝的问题,我在SO中找到了很多解决方案,但仍然无法解决我的问题。

这是我的代码

findViewById<FloatingActionButton>(R.id.fab).setOnClickListener { view ->
                val db = Firebase.firestore

            val city = hashMapOf(
                "name" to "Los Angeles",
                "state" to "CA",
                "country" to "USA"
            )

            db.collection("cities").document("LA")
                .set(city)
                .addOnSuccessListener {
                    Timber.d("DocumentSnapshot successfully written!")
                }
                .addOnFailureListener { e ->
                    Timber.d("Error writing document ${e.message}")
                }
        }

我的 Firestore 规则是

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

如您所见,我设置了公共规则,因此任何人都可以编辑更新或删除记录。

我的权限仍然被拒绝

【问题讨论】:

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


    【解决方案1】:

    不知道是什么问题,

    创建了另一个项目运行(在 Android Studio 和 Firebase 中),相同的代码具有相同的规则。

    效果很好!!

    浪费了我的 3 个小时 :(

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-22
      • 2020-10-25
      • 2020-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-16
      • 2019-03-20
      相关资源
      最近更新 更多