获取审核YouTube频道的详细信息

时间:2018-10-03 07:31:49

标签: youtube-api youtube-data-api

我正试图获取YouTube频道的 auditDetails

根据官方API文档(https://developers.google.com/youtube/v3/docs/channels/list),我应该提供一个包含https://www.googleapis.com/auth/youtubepartner-channel-audit范围的授权令牌。

Authorization

A request that retrieves the auditDetails part for a channel resource must provide an authorization token that contains the https://www.googleapis.com/auth/youtubepartner-channel-audit scope. In addition, any token that uses that scope must be revoked when the MCN decides to accept or reject the channel or within two weeks of the date that the token was issued.

我目前正在尝试通过访问以下URL来获取YouTube频道的auditDetails:

https://www.googleapis.com/youtube/v3/channels?key=xxxxxxxxxx&id=UC9eSXrzVl9ZFLwsNSBgvTog&part=auditDetails

但是,它返回一个权限不足错误,如下所示:

{
  "error": {
    "errors": [
      {
        "domain": "global",
        "reason": "insufficientPermissions",
        "message": "Insufficient Permission"
      }
    ],
  "code": 403,
  "message": "Insufficient Permission"
  }
}

有人可以建议我为各种YouTube频道生成 youtubepartner-channel-audit范围的方法。

2 个答案:

答案 0 :(得分:0)

您遇到的error意味着:

  

为请求提供的 OAuth 2.0令牌指定了以下范围   不足以访问请求的数据。

您可以request for authorization of auditDetails部分获得频道资源:

  

必须提供包含以下内容的authorization token:   https://www.googleapis.com/auth/youtubepartner-channel-audit范围。在   此外,当MCN时,必须撤消使用该范围的所有令牌   决定接受或拒绝该频道,或者在   令牌发行的日期。

然后,您可以将范围添加到OAuth登录请求中。

答案 1 :(得分:0)

为了引入scopes,需要创建包含那些作用域的authorization token

可以通过API控制台中的Credentials page创建授权凭据。

Create credentials

但是在创建 OAuth客户端ID 授权凭据之前,要求用户在consent screen上设置产品名称。

consent screen本身上,用户可以根据应用程序要求添加多个scopes

Add scope