firebase - Firestore 错误:流以状态关闭:PERMISSION_DENIED
问题描述
我正在尝试对某些数据使用 firestore,但在 firestore 控制台错误中看不到任何数据:
(c4326c7) Stream closed with status: Status{code=PERMISSION_DENIED, description=Cloud Firestore API has not been used in project 508621789005 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firestore.googleapis.com/overview?project=508621789005 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., cause=null}.
虽然我允许读,写规则为真。
val db = FirebaseFirestore.getInstance()
// Create a new user with a first and last name
val user: MutableMap<String, Any> = HashMap()
user["first"] = "Ada"
user["last"] = "Lovelace"
user["born"] = 1815
// Add a new document with a generated ID
db.collection("users")
.add(user)
.addOnSuccessListener { documentReference ->
Log.d(
TAG,
"DocumentSnapshot added with ID: " + documentReference.id
)
}
.addOnFailureListener { e -> Log.w(TAG, "Error adding document", e) }
规则:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
解决方案
用这个替换你的规则并尝试:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{multiSegment=**} {
allow read, write;
}
}
}
推荐阅读
- python - 从另一个数组中的一个numpy数组中获取值的频率
- javascript - 从 api 调用获取数组以填充状态
- sql - Angularjs 写入 Azure SQL 表
- ag-grid - 如何设置 ag-grid headerName 进行翻译
- matlab - 从图像中去除部分模糊
- r - 如何使用 apply 直接从函数的参数中命名元素列表
- elasticsearch - 从 mysql 错误导入数据 - 管道已终止
- dhcp - ISC dhcrelay 未将 DISCOVER 数据包转发到 dhcp 服务器
- python - Wordcloud-枕头问题
- asp.net-mvc - 我无法在服务器端接收 serializeEditData 的 postData