【发布时间】:2019-01-31 00:49:53
【问题描述】:
我的 Firestore 中有以下规则
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId}/{documents=**} {
// Only the authenticated user who authored the document can read or write
allow read: if request.auth.uid == userId;
allow write;
}
}
}
这似乎不起作用,我正在使用 Rest API 来获取数据 对于身份验证,我调用: https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=[API_KEY]
一旦通过身份验证,我们将获得 idToken 并作为下一个 URL 的授权标头传递 https://firestore.googleapis.com/v1beta1/projects//databases/(默认)/documents/users
users 集合以 id 作为文档名称,而 value 只是一堆虚拟键。
当我运行客户端时,我得到的错误是
{u'status': u'PERMISSION_DENIED', u'message': u'权限缺失或不足。', u'code': 403}
如果我硬编码用户 ID 的值,它就可以工作。因此,{userid} 中返回的值由于某种原因似乎与 UID 不匹配。
有人能帮忙解释一下为什么会这样吗?
谢谢 公羊
【问题讨论】:
标签: firebase google-cloud-firestore firebase-security