Youtube API key - accessNotConfigured error

落爺英雄遲暮 提交于 2020-01-14 04:56:05

问题


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

and I got this error:

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

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?

EDIT: 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

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

Thanks, Alex


回答1:


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

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

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.)

  • You can use forUsername="LEGACY_USERNAME" if you know the legacy username of the YouTube channel, e.g. "GoogleDevelopers" or "LadyGagaVEVO".
  • You can use id="UC..." if you happen to know the id of the channel (which normally begins with "UC").

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.

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

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

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.




回答2:


Is the API key a simple API key, or is it an OAuth 2.0 access token? That API call requires OAuth 2.0 authorization before it'll work.

We recently published a video playlist explaining how to register for both a simple key and a client ID/client secret run some of the samples.

What you need to do here is:

  1. Register for a client ID/client secret
  2. Go through the three legged OAuth 2.0 authorization flow and get an access token
  3. Use that access token to make an API call

We'll post a video at some point about using the OAuth Playground to generate an access token.




回答3:


To Use the Mine=true you need to have an Oauth2 token as well as it is for getting user data.

here is a link you can use that will let you browse it as long as you turn on the authentication in the upper right

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=contentDetails&mine=true&_h=1&




回答4:


  1. Are you sure that you are going through OAuth2 process in your application and getting an OAuth2 key?
  2. Also in the dev console, under Services, did you enable YouTube Data API v3?



回答5:


i solved this issue, because i miss a config on Google Console Dashboard.

if you using google api v3, this is simple way to solve that problem, you only need to enable youtube api via Google Console Dashboard. https://console.developers.google.com



来源:https://stackoverflow.com/questions/17409502/youtube-api-key-accessnotconfigured-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!