I've created a service account for use with the YouTube Content ID API, I'm following the steps under Set up your service account on:
https://developers.google.com/youtube/partner/guides/oauth2_for_service_accounts
The steps seem to be a bit outdated, I am not able to find YouTube Content ID API in Developer console.
I am able to upload a video on a channel. Well, when I'm making requests using this service account, I'm getting forbidden errors. For example the below error is when I'm trying to get a list of content owners.
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."
}
}
Here's the PHP code:
$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'];