截至昨天下午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视频中抓取标题、图像和描述。
您选择的API密钥类型可能不适合接收的流量。这似乎不是防火墙/通信问题,因为它提供了403错误,所以可以对其进行审查。你能为服务器生成一个新的密钥,看看这是否能解决特定IP的问题吗?
另请注意,最初为该项目创建的密钥类型是什么?