YouTube Content ID API返回禁止错误

时间:2019-02-26 06:47:52

标签: youtube-api youtube-data-api

我已经创建了一个用于YouTube Content ID API的服务帐户,我正在按照以下步骤设置您的服务帐户:

https://developers.google.com/youtube/partner/guides/oauth2_for_service_accounts

步骤似乎有些过时,我无法在开发者控制台中找到YouTube Content ID API。

我可以在频道上上传视频。 好吧,当我使用此服务帐户发出请求时,我得到了禁止的错误。例如,以下错误是当我尝试获取内容所有者列表时。

error::::::{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "insufficientPermissions",
    "message": "Insufficient Permission: Request had insufficient authentication scopes."
   }
  ],
  "code": 403,
  "message": "Insufficient Permission: Request had insufficient authentication scopes."
 }
}

这是PHP代码:

$client = new Google_Client();
    $client->setAccessType("offline");
    $client->setApprovalPrompt("force");
    $client->setClientId($OAUTH2_CLIENT_ID);
    $client->setClientSecret($OAUTH2_CLIENT_SECRET);
$client->setScopes(array('https://www.googleapis.com/auth/youtube', 'https://www.googleapis.com/auth/youtubepartner'));
        $youtube = new Google_Service_YouTube($client);

    $youtubePartner = new Google_Service_YouTubePartner($client);
$contentOwnersListResponse = $youtubePartner->contentOwners->listContentOwners(
          array('fetchMine' => true));
          $contentOwnerId = $contentOwnersListResponse['items'][0]['id'];

1 个答案:

答案 0 :(得分:0)

您提到您在Google Developers Console中看不到“ YouTube Content ID API”,我认为您需要检查YouTube Partner Program。请注意,“ YouTube Content ID API供YouTube内容合作伙伴使用,并非对所有开发人员或所有YouTube用户都可用”。 page最顶部的注释中对此进行了说明。