YouTube Api - 无法搜索:com.google.api.client.googleapis.json.GoogleJsonResponseException:403 禁止访问

YouTube Api - Could not search: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden

我一直在关注 this tutorial 创建 Youtube 应用程序。我创建了 Browser-Android API Key 并在我的项目中尝试了它们。但是当我尝试运行 它并搜索我得到:

Could not search: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
   "code" : 403,
   "errors" : [ {
     "domain" : "usageLimits",
     "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.",
     "reason" : "ipRefererBlocked",
     "extendedHelp" : "https://console.developers.google.com"
   } ],
   "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 设置为允许的任何引荐来源来解决问题。

您只需: Remove/Edit 引用 "Any referer allowed" 部分 "Key for browser applications".

将其设置为 "Any referer allowed" 很简单,就像擦除所有 referer 允许的输入一样。