访问Youtube Data API时ipRefererBlocked

时间:2016-01-05 14:20:19

标签: amazon-web-services youtube-api youtube-data-api

截至昨天下午1点左右,我们无法再从AWS上的服务器使用Youtube Data API。我们现在收到来自云的每个请求的以下响应:

curl "https://www.googleapis.com/youtube/v3/videos?id=GO5G-funzPI&key=OUR_API_KEY&part=contentDetails"
{
 "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."
 }
}

当我查看开发人员控制台时,此项目的API密钥具有IP地址限制。我们尝试在开发者控制台中将外部IP和内部IP范围列入白名单,但它没有任何效果。白名单范围现已删除,但AWS中仍会收到相同的消息。

在AWS之外使用相同的API密钥时,不会收到此消息;如果我在家里或办公室网络上从我的机器上运行它,我会得到预期的视频数据:

curl "https://www.googleapis.com/youtube/v3/videos?id=GO5G-funzPI&key=OUR_API_KEY&part=contentDetails"
{
 "kind": "youtube#videoListResponse",
 "etag": "\"kuL0kDMAqRo3pU7O0pwlO-Lfzp4/Qye0F1aiqHjVYlPPicUgbMvEoOQ\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#video",
   "etag": "\"kuL0kDMAqRo3pU7O0pwlO-Lfzp4/wMAduvfW4vn2Up8MEhRCbpCtY-w\"",
   "id": "GO5G-funzPI",
   "contentDetails": {
    "duration": "PT28S",
    "dimension": "2d",
    "definition": "sd",
    "caption": "true",
    "licensedContent": true
   }
  }
 ]
}

有什么想法吗?这在我们的CMS后端运行,以便在加载时从YouTube视频中删除标题,图像和说明。

1 个答案:

答案 0 :(得分:2)

您选择的API密钥类型可能不适合所接收的流量。这似乎不是防火墙/通信问题,因为它提供403错误,因此可以被忽略。您是否可以为服务器生成新密钥,并查看是否可以解决该特定IP的问题?

另外,最初为此项目创建了哪种类型的密钥?