youtube api上的“403 - usageLimits”

时间:2015-05-06 15:28:05

标签: android api youtube

我从我的Android应用程序到YouTube API的调用中得到了这个JSON响应:

"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."
}

我的url是正确的(根据youTube search list

我在某处读到了我应该发送一个浏览器密钥而不是一个android-key,但它不起作用。

3 个答案:

答案 0 :(得分:2)

这个错误对我来说似乎很清楚:

您的网址很好,但您刚刚超过了Youtube API上的配额。

  

您的API密钥上配置了每IP或每个Referer限制,并且请求与这些限制不匹配。

我相信这仍然是真的:

  

YouTube Data API第3版具有Google API控制台中列出的具体配额号,您可在其中注册API密钥。您可以使用30,000单位/秒/用户和50,000,000每天。

答案 1 :(得分:0)

原因在你得到的答复中解释:

  

如果允许来自此IP或引用者的请求,请使用Google Developers Console更新您的API密钥配置。

您的请求被阻止,因为它来自与该密钥的IP限制不匹配的IP地址。我不知道你是使用浏览器还是服务器密钥。我创建了一个服务器密钥,我用它来测试我的浏览器和服务器。创建服务器密钥后,检查“API访问”选项卡上的“允许的IP”选项,并确保其为空,以允许提供有效密钥的所有IP。同样,如果您使用浏览器密钥,请检查“允许的引荐来源”并确保其空白:https://code.google.com/apis/console/?noredirect

答案 2 :(得分:0)

  1. 如果您添加了域限制,则可以从“接受来自这些HTTP引荐者(网站)的请求”中删除域限制。一旦工作,您可以稍后添加DOMAIN名称限制。 如果添加了域限制,还需要域所有权验证过程。

  2. 生成并使用“浏览器”类型密钥,如果整合到网站/网页。

  3. 感谢。