通过 CMS 帐户使用 YouTube 分析 API [英] Using the YouTube Analytics API with a CMS account

查看:48
本文介绍了通过 CMS 帐户使用 YouTube 分析 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用 CMS 帐户获取 youtube 分析 API 数据时收到 403 Forbidden 错误.

I'm getting a 403 Forbidden error when trying to get youtube analytics api data using a CMS account.

只是想确认一下,CMS 帐户与服务帐户是否相同?

Just to confirm, is a CMS account the same thing as a Service account?

我可以获得 oauth2 用户拥有的频道的分析数据,但我在我可以通过我的 CMS 帐户访问但不是内容所有者的任何其他频道上获得 403.(我在 CMS 帐户上拥有管理员帐户级别,并且我收到 403 错误的频道具有托管"关系)

I can get analytics data for channels that are owned by the oauth2 user but I get the 403 on any other channels that I have access to through my CMS account but am not the content owner of. (I have Administrator account level on the CMS account and the channels I get 403 error on have "Managed" relationship)

问题:是否有计划让 youtube.analytics api 支持查询在 CMS 帐户下管理的频道?

Question: Are there any plans to have youtube.analytics api support for querying channels managed under a CMS account?

似乎因为我可以使用该帐户使用 CMS UI 获取这些渠道的所有分析数据,所以我应该能够使用 API 执行相同的操作.

It seems that since I can use that account to get all the analytics data for these channels using the CMS UI that I should be able to do the same using the API.

推荐答案

YouTube 内容管理系统帐户与 服务帐号.如果您以服务帐户身份进行身份验证,您将无法使用 YouTube API,因为该服务帐户将无法访问任何实际的 YouTube 频道.但是,作为 CMS 帐户进行身份验证可以满足您的要求.

A YouTube Content Management System account is not the same thing as a Service Account. You won't get far with the YouTube APIs if you authenticate as a Service Account, since that Service Account won't have access to any actual YouTube channels. Authenticating as a CMS account, however, will give you what you want.

其中很多最近已经投入生产,所以让我在这里列出完整的步骤,解释拥有 YouTube CMS 访问权限的人如何针对他们管理的频道和视频运行 YouTube 分析 API 报告.

A lot of this recently made it into production, so let me lay out the full steps here explaining how folks with YouTube CMS access can run YouTube Analytics API reports against the channels and videos they manage.

(可选)通过 OAuth 2 授权作为 CMS 帐户,同时使用 https://www.googleapis.com/auth/youtube.readonlyhttps://www.googleapis.com/auth/youtubepartner 范围,制作 YouTube 数据 API v3 channels.list() 使用以下参数调用:part=snippet,contentDetailsmanagedByMe=truemaxResults=50onBehalfOfContentOwner=CONTENT_OWNER_ID.CONTENT_OWNER_ID 是您必须在此处硬编码的一个值,它应该设置为您的 YouTube CMS 帐户的合作伙伴代码".这将为您返回一个由您的 CMS 帐户管理的最多 50 个频道的列表.(如果您需要超过 50 个,则需要翻阅结果.)每个频道的 id 将在 channel.id 以及其他有用的信息(如上传列表 id,如果您想获取该频道中的视频列表)也将返回.

(Optional) While authorized via OAuth 2 as the CMS account, using both the https://www.googleapis.com/auth/youtube.readonly and https://www.googleapis.com/auth/youtubepartner scopes, make a YouTube Data API v3 channels.list() call with the following parameters: part=snippet,contentDetails, managedByMe=true, maxResults=50, onBehalfOfContentOwner=CONTENT_OWNER_ID. CONTENT_OWNER_ID is the one value that you'll have to hardcode here, and it should be set to the "partner code" for your YouTube CMS account. This will give you back a list of up to 50 channels that your CMS account manages. (If you need more than 50, you'll need to page through the results.) The id of each channel will be returned in channel.id, and other useful information (like the uploads list id, if you want to get the list of videos in that channel) will also be returned.

如果您已经知道要针对其生成报告的频道的 UC... 频道 ID,则可以跳过该步骤并直接转到 Analytics 报告.

If you already know the UC... channel id for the channel you want to run reports against, you could skip that step and go directly to the Analytics report.

要在被授权为 CMS 帐户的受管频道上运行频道级报告,请制作 YouTube 分析 API使用以下参数请求:ids=contentOwner==CONTENT_OWNER_IDfilters=channel==UC...,然后是您想要的任何其他报告参数.

To run a channel-level report on a managed channel, while authorized as the CMS account, make a YouTube Analytics API request with the following parameters: ids=contentOwner==CONTENT_OWNER_ID, filters=channel==UC..., and then any other report parameters you want.

要运行视频级报告,请设置 ids=contentOwner==CONTENT_OWNER_IDfilters=video==VIDEO_ID,其中 VIDEO_ID 是CMS 帐户管理的任何频道中的任何视频的 ID.

To run a video-level report, set ids=contentOwner==CONTENT_OWNER_ID and filters=video==VIDEO_ID, where VIDEO_ID is the id of any video in any channel that the CMS account manages.

文档中有更多关于内容所有者报告的详细信息.

There are more details about content owner reports in the docs.

这篇关于通过 CMS 帐户使用 YouTube 分析 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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