当提出请求时:
https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=5&key=<MY_API_KEY>&q=dogs
我收到以下错误响应:
"error": {
"code": 403,
"message": "Requests from referer \u003cempty\u003e are blocked.",
"errors": [
{
"message": "Requests from referer \u003cempty\u003e are blocked.",
"domain": "global",
"reason": "forbidden"
}
],
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_HTTP_REFERRER_BLOCKED",
"domain": "googleapis.com",
"metadata": {
"consumer": "projects/119952101582",
"service": "youtube.googleapis.com"
}
}
]
}
}
1条答案
按热度按时间5gfr0r5j1#
出现错误是因为请求的http引用违反了API密钥HTTP限制。
请检查项目的API_KEY设置。
您可以在the documentation feature中尝试该请求并查看结果:
网址:
https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=5&type=video&key=[YOUR_API_KEY]
结果: