【发布时间】:2020-08-17 13:32:57
【问题描述】:
我已禁用我的安全规则,因此任何人都可以更新、写入、创建、读取、删除allow read, write, delete, update, create;
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write, delete, update, create;
}
}
}
当我尝试使用`POST https://firestore.googleapis.com/v1/{database=projects/*/databases/*}/documents:batchWrite
正文如下
{
"writes": [
{
"update": {
"name": "projects/project_id/databases/(default)/documents/service_order/352003090342435.5f357270173e8c70878.-9486573",
"fields": {
"managed_by": {
"booleanValue": "false"
},
"location2": {
"booleanValue": "false"
},
"made_by": {
"stringValue": "352003090342435.5eda4f3c17284c58460.90921842"
},
"phone2": {
"stringValue": "0665439307"
},
"state": {
"stringValue": "confirm"
},
"write_date": {
"stringValue": "1597664391000"
},
"made_by_name": {
"stringValue": "FaridBenabdallah"
},
"description": {
"stringValue": "e1"
},
"accepted_offer": {
"booleanValue": "false"
},
"id": {
"stringValue": "352003090342435.5f357270173e8c70878.-9486573"
},
"location1": {
"stringValue": "352003090342435.5f3572a0173e8c7c336.-8281409"
},
"date_order": {
"booleanValue": "false"
},
"order_type": {
"stringValue": "Minuiserie"
},
"phone1": {
"stringValue": "0657331995"
}
}
},
"updateMask": {
"fieldPaths": [
"managed_by",
"location2",
"made_by",
"phone2",
"state",
"write_date",
"made_by_name",
"description",
"accepted_offer",
"id",
"location1",
"date_order",
"order_type",
"phone1"
]
}
}
]
}
`rest api 它总是以拒绝的权限响应
{
"error": {
"code": 403,
"message": "Missing or insufficient permissions.",
"status": "PERMISSION_DENIED"
}
}
但是,当我尝试使用 Google OAuth 2.0 时,它可以正常工作
所以当我在没有authoirzation header 的情况下使用它时,batchWrite 有问题
【问题讨论】:
-
我建议编辑问题以显示您如何提出此请求的完整详细信息。问题中应该有足够的信息,以便任何人都可以重现该行为。
-
另外,在 Stack Overflow 上,不要显示代码或文本的图片。将文本复制到问题本身中,以便于阅读、复制和搜索。
-
@DougStevenson 感谢我编辑它的建议
-
我看不到您在哪里添加任何用于身份验证的标头。如果您没有正确执行此操作,查询将被拒绝。
-
我假设您可以调用其他一些 firestore api 方法,而无需使用之前的安全规则勾选 Google Oauth 复选框。我说的对吗?
标签: firebase google-cloud-firestore firebase-security