【发布时间】:2015-06-05 03:12:30
【问题描述】:
使用 Google Storage JSON API 时出现以下错误:
$ curl -v 'https://www.googleapis.com/storage/v1/b/MY-BUCKET/o?key=MY_API_KEY'
* Hostname was NOT found in DNS cache
* Trying 64.233.186.95...
* Connected to www.googleapis.com (64.233.186.95) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
* Server certificate: *.storage.googleapis.com
* Server certificate: Google Internet Authority G2
* Server certificate: GeoTrust Global CA
> GET /storage/v1/b/MY-BUCKET/o?key=MY_API_KEY HTTP/1.1
> User-Agent: curl/7.37.1
> Host: www.googleapis.com
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< Vary: X-Origin
< Content-Type: application/json; charset=UTF-8
< Date: Tue, 31 Mar 2015 16:57:40 GMT
< Expires: Tue, 31 Mar 2015 16:57:40 GMT
< Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
* Server GSE is not blacklisted
< Server: GSE
< Alternate-Protocol: 443:quic,p=0.5
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
"extendedHelp": "https://console.developers.google.com"
}
],
"code": 403,
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
}
}
但一切似乎都配置正确。我使用的密钥被列为允许任何 IP:
API 本身是活跃的:
并且该项目已正确配置了计费信息:
我已尝试启用和禁用 API 并刷新结算信息。没有任何帮助。什么是下一个步骤?试试 AWS?
【问题讨论】:
-
你从哪个 IP 地址连接?
-
我试图重现您的问题,但到目前为止我还无法重现。尝试删除 API 密钥并生成一个新密钥。另外,如果可能,请尝试使用不同的 IP。
-
我也无法重现该问题。我确实注意到 Stackoverflow 上有一些案例,供人们使用 Google Calendar API 和 Youtube API 遇到相同问题。解决他们的问题是: - 从凭据窗格中删除服务器密钥 - 停用/重新激活所需的 API - 创建新的服务器密钥 我遇到的一个问题是错误 401 授权。为了解决这个问题,我运行了 gsutil acl set public-read gs://MY-BUCKET/
-
您找到解决此问题的方法了吗?
-
嗨亚当,我自己回答了这个问题;)
标签: google-api google-cloud-storage