您没有权限在Python Eve中访问所请求的资源

时间:2015-07-07 17:06:08

标签: python mongodb flask eve

使用DELETE(http://localhost:5000/tax/559c0180b9f1f1072f240065)命中REST端点时,收到错误。错误如下。 Tax是我尝试删除的集合,URL中的以下值是我要删除的文档的ID。 Status 403 FORBIDDEN Show explanation Loading time: 7 Request headers Accept: application/json Origin: chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo CSP: active User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36 Content-Type: application/x-www-form-urlencoded Accept-Encoding: gzip, deflate, sdch Accept-Language: en-US,en;q=0.8 Response headers Content-Type: application/json Content-Length: 180 Server: Eve/0.6-dev0 Werkzeug/0.10.4 Python/2.7.6 Date: Tue, 07 Jul 2015 16:46:40 GMT

{ _status: "ERR" _error: { message: "You don't have the permission to access the requested resource. It is either read-protected or not readable by the server." code: 403 }- } 我使用的有效载荷是{" KONG":" Donkey"}

我该怎么做才能解决这个问题?

我使用的代码位于以下链接

https://gist.github.com/anonymous/fda6080f3e7910d4be84 https://gist.github.com/anonymous/3bab73901f901087177b

1 个答案:

答案 0 :(得分:0)

您还需要在请求中提供If-Match标题(以及文档ETag)。见Data Integrity and Concurrency Control。默认情况下,所有编辑操作都需要使用Etags,但您只需将IF-MATCH设置为False即可选择退出:

  

如果您的用例需要,您可以选择完全禁用并发控制。可以通过将IF_MATCH配置变量设置为False来禁用ETag匹配检查(请参阅全局配置)。禁用并发控制时,不会为响应提供etag。您应该小心禁用此功能,因为您有效地打开API会冒旧版本替换文档的风险。