YouTube 数据 API 返回“访问未配置”错误,尽管它已启用
Posted
技术标签:
【中文标题】YouTube 数据 API 返回“访问未配置”错误,尽管它已启用【英文标题】:YouTube Data API returns "Access Not Configured" error, although it is enabled 【发布时间】:2019-08-13 10:27:16 【问题描述】:我内部使用的基于此示例 (https://developers.google.com/youtube/v3/quickstart/js) 检索 YouTube 视频统计信息的网络解决方案现在无法正常工作。不知道它到底是什么时候发生的,但它曾经在几个月前工作过。
我现在尝试运行未经编辑的示例代码(当然,除了调整 CLIENT_ID 之外),我得到了完全相同的错误:
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. YouTube Data API has not been used in project 123 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=123 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"extendedHelp": "https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=123" ], "code": 403, "message": "Access Not Configured. YouTube Data API has not been used in project 123 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=123 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
当我在开发者控制台中检查 YouTube API 时,它显示启用状态,并且与此 API 兼容的凭据包括用于验证客户端的 ID。当我重试 API 调用尝试时,我可以看到凭据使用增量的统计信息,这些指标反映了请求的数量,还显示错误率为 100%。但是控制台中没有关于这些失败尝试的额外信息来帮助调试问题。
我已经删除并重新创建了 API 密钥和 OAuth 密钥,但这并没有改变任何东西。
如果在开发者控制台端有任何关于这些错误的额外信息,例如超出客户报价,我可以看到如何解决这个问题。现在我完全卡住了。
【问题讨论】:
API 的 subscriptions.list 部分有同样的问题。 上传视频时出现同样的错误 【参考方案1】:创建一个新项目
奇怪的是,创建一个新项目只会让 API 正常工作!
【讨论】:
【参考方案2】:不幸的是,错误消息是一条红鲱鱼:您的项目对 YouTube 数据 API 服务的访问权限是 automatically disabled after a 90 day inactivity period。
您应该已经通过电子邮件收到有关此操作的通知,其中还包含重新获得访问权限所需采取的步骤:请填写并提交exceptions form。
【讨论】:
我删除并创建了一个新项目,它工作正常。禁用和重新启用 API 和密钥是不够的。谢谢。【参考方案3】:尝试使用新的 oAuthCliedID 和 oAuthClientSecret 开始一个新项目
【讨论】:
【参考方案4】:在经过大量的摆弄之后,似乎为我做了这件事:
-
转到项目的
OAuth consent screen
。
输入Application name
。
请按Save
。
瞧,5 分钟后它开始工作了。
【讨论】:
我认为您看到了不同的问题。如果您的 API 访问权限已被禁用,这将无济于事。以上是关于YouTube 数据 API 返回“访问未配置”错误,尽管它已启用的主要内容,如果未能解决你的问题,请参考以下文章
YouTube 数据 API 不再从 search.list 返回活跃的直播流
访问未配置。您的项目未启用 API (Google+ API)。请使用 Google Developers Console 更新您的配置