CMS channel list using Youtube API with onBehalfOfContentOwner

故事扮演 提交于 2019-12-06 04:28:17

One of two things is probably at work here:

  1. You are authenticating with the account which grants access to the CMS, but the CONTENT_OWNER_ID you provided in your youtube.channels().list() method is incorrect.
  2. You are providing the correct CONTENT_OWNER_ID, but authenticating with the wrong account.

Case 1

You may simply need to include the correct CONTENT_OWNER_ID for the onBehalfOfContentOwner parameter in your youtube.channels().list() method (although, you may have left this blank in your post for privacy).

To double-check, you can find the value for CONTENT_OWNER_ID by invoking the API through this form. Make sure that you are authenticated correctly (ie., using the account with access to the CMS you want), and you'll receive a JSON response, something like this:

{
 "kind": "youtubePartner#contentOwnerList",
 "items": [
  {
   "kind": "youtubePartner#contentOwner",
   "id": CONTENT_OWNER_ID,
   "displayName": DISPLAY_NAME
   etc.
  }
 ]
}

Simply include whatever CONTENT_OWNER_ID you want from this response in your channels().list() method (making sure, again, that you are properly authenticated), and voila.

Case 2

If that doesn't solve your problem, then you may be providing the correct CONTENT_OWNER_ID, but you are authenticating with the wrong account.

Before running your script again, double-check that you delete the file containing your temporary access token (it will have a filename like "YOUR_FILENAME-oauth2.json"). Then, run your script again; making sure that, when prompted to select an account for authentication, you select the one that corresponds with the CONTENT_OWNER_ID you set.

tl:dr;

Basically, there must be agreement between the account with which you authenticate, and the CONTENT_OWNER_ID you provide.

Finally, you do not need an API key to invoke the API in this way; you either need an API key or a properly-authenticated OAuth 2.0 access token. Here are the docs.

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