为什么Youtube"渠道"API不会返回"contentOwnerDetails"数据?

mic*_*obg 6 youtube-api

我正在尝试调用Youtube 渠道 API,但响应没有contentOwnerDetails.问题是什么?

GET https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails%2CcontentOwnerDetails&mine=true&key={YOUR_API_KEY}
Run Code Online (Sandbox Code Playgroud)

Ana*_*u C 0

对于您的GET方法 URI

https://www.googleapis.com/youtube/v3/channels?part=id%2CcontentDetails%2CcontentOwnerDetails&mine=true&key={YOUR_API_KEY}
Run Code Online (Sandbox Code Playgroud)

JSON响应如下

{
  "error": {
    "errors": [
      {
        "domain": "youtube.parameter",
        "reason": "authorizationRequired",
        "message": "The request uses the <code>mine</code> parameter but is not properly authorized.",
        "locationType": "parameter",
        "location": "mine"
      }
    ],
    "code": 401,
    "message": "The request uses the <code>mine</code> parameter but is not properly authorized."
  }
}
Run Code Online (Sandbox Code Playgroud)

根据YouTube 数据 API - 错误

401(未经授权)-authorizationRequired-请求使用了mine参数,但未得到正确授权。

我的参数值必须设置为 true 以指示 API 仅返回经过身份验证的用户拥有的通道。(布尔值)

推论:您没有内容所有者对内容的授权,即 YouTube 频道所有者可能拒绝您的应用程序访问频道内容。

这是一个权限问题。URI 中的channelId 在哪里?也许应该添加它。

  • 不,这不是权限问题。我已获得授权,这不是问题。我使用此页面(https://developers.google.com/youtube/v3/docs/channels/list#try-it)提出请求并给予许可。请求正确,没有错误,因此不存在身份验证问题。我的问题是为什么响应中缺少 contentOwnerDetails?它包含在“部分”列表中。我需要 contentOwnerDetails.contentOwner 来获取用户的 id。 (5认同)
  • 这个问题的解决办法是什么? (2认同)