I try to use the YouTube API, but when I wish to use the LiveBroadcasts.list
API.
When I use the same JSON key to list my playlist it's OK... I don't understand why.
$client = new \Google_Client();
$client->setAuthConfig(__DIR__ . '/../../key/youtube_client.json');
$client->setApplicationName('Broadcast');
$client->setScopes([
'https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtube.force-ssl',
'https://www.googleapis.com/auth/youtube.upload',
'https://www.googleapis.com/auth/youtube.readonly'
]);
$service = new \Google_Service_YouTube($client);
$broadcastsResponse = $service->liveBroadcasts->listLiveBroadcasts(
'id,snippet,contentDetails',
array(
'broadcastType' => 'persistent',
'mine' => 'true',
)
);
The error message is:
{ "error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "errors": [ { "message": "Login Required.", "domain": "global", "reason": "required", "location": "Authorization", "locationType": "header" } ], "status": "UNAUTHENTICATED" } }
Can someone help me to know where is my mistake?
$client
. – stvarlist_broadcasts.php
. – stvar