1
votes

Youtube Live Streaming API has really thorough documentation, and I went through it as well as usage examples. Recently I started to get 403 error.

The full signature of the error is:

Error calling POST 

https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet%2Cstatus%2CcontentDetails: 

(403) Request is not authorized

And I can't find out the reason behind it. On a day start it was all working fine with a google account credentials and OAuth keys. Then after a few requests succeeded it went down with the 403. Same credentials and keys were used.

I strongly believe there are limitations in play, but which are this limitations or how to bypass them I can't help to find in docs or elsewhere.

the code goes like this (up to the breaking point):

$liveStreamingApi = new LiveStreamingApi();
$youtube = $liveStreamingApi->setLiveBroadcasts($returnUrl, null, LiveStreamingApi::CREATE);

$broadcastSnippet = new \Google_Service_YouTube_LiveBroadcastSnippet();
$broadcastSnippet->setTitle($model->name);

$broadcastSnippet->setScheduledStartTime(STARTTIME);
$broadcastSnippet->setIsDefaultBroadcast('1');

$status = new \Google_Service_YouTube_LiveBroadcastStatus();
$status->setPrivacyStatus($privacy);

$broadcastInsert = new \Google_Service_YouTube_LiveBroadcast();
$broadcastInsert->setSnippet($broadcastSnippet);
$broadcastInsert->setStatus($status);
$broadcastInsert->setKind('youtube#liveBroadcast');

$broadcastsResponse = $youtube->liveBroadcasts->insert('snippet,status,contentDetails', $broadcastInsert, array());

where $liveStreamingApi->setLiveBroadcasts sets all the essential scopes in https (force-ssl, youtube, youtubepartner) $youtube->liveBroadcasts->insert throws the aforementioned error

1
Can you share your code and your whole request? - Mr.Rebot
We have been running into the same issue and our quotas are nowhere near close to capacity - Ulises Giacoman
Same here, with only 168 request showing after test creating about 10 livestreams. - Ganbayar Gansukh

1 Answers

1
votes

There is a quota limitation on youtube API that limit your request that you can make in day. The default quota value it's 1000000 per day splitted for the whole day. however every API request cost a different number of quota points.If you pass your quota limit you'd get an error message that is insufficientLivePermissions. you can check your quota usage here: https://developers.google.com/youtube/v3/determine_quota_cost however you can consider that a insert request cost about 1600 of quota.