【发布时间】:2019-07-19 15:51:50
【问题描述】:
我已经创建了一个用于 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'];
【问题讨论】:
-
您提到您在Google Developers Console 中看不到“YouTube Content ID API”,我认为您需要检查YouTube Partner Program。请注意“YouTube Content ID API 仅供 YouTube 内容合作伙伴使用,并非所有开发者或所有 YouTube 用户都可以访问”。在page 最顶部的注释中说明了这一点。
标签: youtube-api youtube-data-api