Google 存储 API 禁止的 ipRefererBlocked 错误

Google Storage API Forbidden ipRefererBlocked Error

我在使用 Google 存储 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 本身处于活动状态:

并且该项目已正确配置结算信息:

我试过启用和禁用 APIs 并刷新帐单信息。没有任何帮助。什么是下一个步骤?试试 AWS?

对于后代来说,这就是发生的事情:

我在同一个数据中心(Newark/NJ 中的 Linode)运行了一个不同的 VM,它工作得很好,所以问题似乎不是我的关键,而是我的 IP 本身。

为了弄清问题的真相,我不得不向 Google Cloud 支付 150.00 美元,这样他们才能让我开具支持票并描述问题。

在接下来的两天里,我与一位支持人员争论——虽然非常有礼貌——但我总是认为错误是我的结果而不是他们的。

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

鉴于虚拟机位于新泽西州——通过 traceroute 很容易看出这一点——他们告诉我他们将不得不手动覆盖系统并将我的 IP 放回美国。这需要三天时间,所以我等了。

三天后,我收到一封电子邮件,告诉我要测试所有内容,我照做了。它没有用。在又发了几封电子邮件并又等了一天之后,他们终于修好了。

最糟糕的是 Google 支持人员指责我的公司与受限国家开展业务并充当来自伊朗的流量代理。那是荒谬的,它真的冒犯了我们,因为即使在犯了错误之后他们仍然想责怪我们没有做错。

我们告诉两位工程师将 VM 倒转,看看他们是否能找到任何证据表明它已被黑客入侵,当然他们找不到。这是一个完全修补的 Ubuntu 14.04 服务器,只能通过私钥 SSH 并且远程 root 登录被禁用。

伙计们,故事就这样结束了。花费 150.00 美元通知 Google 他们自己的错误,并且不得不努力寻找解决方案。

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