Google Storage API禁止ipRefererBlocked错误

时间:2015-03-31 17:07:17

标签: google-api google-cloud-storage

使用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 Key configuration

API本身是活跃的:

APIs Enabled

项目正确配置了结算信息:

Correctly configured billing

我已尝试启用和停用API并刷新结算信息。什么都没有帮助。什么是下一个步骤?试试AWS?

1 个答案:

答案 0 :(得分:2)

对于后人来说,这是发生了什么:

我在同一个数据中心(纽瓦克/新泽西州的Linode)中创建了一个不同的虚拟机,它工作得很好,所以问题似乎不是我的关键,而是我的IP本身。

为了解决这个问题,我不得不向Google Cloud支付150美元,这样他们就可以让我打开支持票并描述问题。

接下来的两天,我和支持人员争论说 - 虽然很有礼貌 - 总是认为错误是我最终的而不是他们的错误。

在写了6000个字符的回复后,他最终决定与某人核实并发现我的IP已被Google交通自动化系统阻止,因为它错误地检测到我的IP来自受限制的国家(伊朗)。

鉴于VM位于新泽西州 - 很容易通过traceroute看到它们 - 他们告诉我他们必须手动覆盖系统并将我的IP放回美国。这需要三天,所以我等了。

三天后,我收到一封电子邮件告诉我要测试一切,所以我做了。它没用。又过了几封电子邮件,等了一天,他们终于修好了。

在整个混乱局面之上,有一位Google支持人员指责我的公司与受限制的国家开展业务,并代理来自伊朗的流量。这是荒谬的,它真的冒犯了我们,因为即使犯了错误,他们仍然想责怪我们没有做错任何事。

我们告诉两位工程师向后转动虚拟机,看看他们是否能找到任何被黑客攻击的证据,当然他们也不能。它是一个完全修补的Ubuntu 14.04服务器,只能通过私钥SSH和远程root登录被禁用。

这就是故事的结局,伙计们。消费150.00美元通知谷歌他们自己的错误,并且不得不争取解决方案。

哦,还有一件事:我们正在迁移到AWS。