Youtube API 密钥 - accessNotConfigured 错误 [英] Youtube API key - accessNotConfigured error

查看:35
本文介绍了Youtube API 密钥 - accessNotConfigured 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 YouTube 上为 Android 应用注册了我的应用程序,并获得了一个 API 密钥.然后我尝试通过我的浏览器进行 api 调用以这样尝试:

I registered my application with YouTube for an Android app, and got an API key. And then I tried to make an api call through my browser to try it like this:

https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&key=my_api_key

我收到了这个错误:

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured"
   }
  ],
  "code": 403,
  "message": "Access Not Configured"
 }
}

但我确实配置了我的帐户并将服务设置为使用 YouTube Data API v3知道我还需要做什么吗?

But I did configure my account and set the services to work with YouTube Data API v3 Any idea what I still need to do?

在创建 clientId 并启用所有需要的服务后,我得到了这个响应:

After creating the clientId and enabling all the needed services, I got this response:

{
 "error": {
  "errors": [
   {
    "domain": "youtube.parameter",
    "reason": "authorizationRequired",
    "message": "Unauthorized",
    "locationType": "parameter",
    "location": "mine"
   }
  ],
  "code": 401,
  "message": "Unauthorized"
 }
}

到我粘贴到浏览器中的这个网址:

to this url that I pasted into the browser:

https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&key=key_for_server_apps

和我在浏览器中输入这个 url 时的结果相同

and the same result as originally when I entered this url in the browser

https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&key=key_for_browser_apps

谢谢,亚历克斯

推荐答案

综合一些不同的东西,基于原发帖者对其他答案的评论:

Synthesizing a few different things, based on the original poster's comments to the other answers:

此外,我试图拉取的 YouTube 频道实际上不是我的.它是一个受欢迎的 YouTube 节目.我怎么能这样做?

Also, the YouTube channel I am trying to pull isn't actually mine. It is a popular YouTube show. How could I do that?

您要进行的 API 调用是 youtube.channels.list(),您可以传入两个参数之一来检索任意频道的频道信息.(您不想使用 mine=true,因为您说您不想检索自己的频道.)

The API call that you want to make is youtube.channels.list(), and you can pass in one of two parameters to retrieve the channel info for an arbitrary channel. (You don't want to use mine=true since you say that you're not trying to retrieve your own channel.)

  • 您可以使用 forUsername="LEGACY_USERNAME" 如果您知道 YouTube 频道的旧用户名,例如GoogleDevelopers"或LadyGagaVEVO".
  • 您可以使用 id="UC..." 如果您碰巧知道频道的 id(通常以UC"开头).

您还需要为 part= 参数包含一个值.part="snippet" 通常就足够了.对于此类 API 调用,您不必通过 OAuth 2 流程,您只需提供一个有效的 API 密钥,该密钥已为其启用了 YouTube 数据 API v3.Ikai 发布链接的视频系列是注册该 API 密钥的很好指南.

You'll also need to include a value for the part= parameter. part="snippet" is normally sufficient. You don't have to go through the OAuth 2 flow for this kind of API call, and you can just supply a valid API Key that's has the YouTube Data API v3 enabled for it. The video series that Ikai posted a link to is a good guide to registering for that API Key.

以下是 youtube.channels.list(part="snippet", forUsername="GoogleDevelopers") 调用的工作示例,使用交互式 API Explorer:

Here's a working example of a youtube.channels.list(part="snippet", forUsername="GoogleDevelopers") call, using the interactive API Explorer:

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=snippet&forUsername=GoogleDevelopers

它对应于以下网址:https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername=GoogleDevelopers&key={YOUR_API_KEY}

It corresponds to the following URL: https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername=GoogleDevelopers&key={YOUR_API_KEY}

由于您询问的是 Android 应用程序,因此最好使用 Java 客户端库来发出请求,而不是请求原始 URL.此页面上的示例代码应该可以帮助您入门.

Since you're asking about an Android application, it's probably a good idea to use the Java client libraries to make your requests instead of requesting the raw URL. The sample code on this page should help you get started.

这篇关于Youtube API 密钥 - accessNotConfigured 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆