Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allowing Google Service Account YouTube Upload Access via API v3

I want to automatically upload videos to YouTube without user involvement so I've created a service account, jumped through the hoops, all was looking great, then the upload, chunk one, is attempted and my code bombs with this Google_Exception exception:

"Failed to start the resumable upload (HTTP 401: youtube.header, Unauthorized)"

I then dug and found on the YouTube API v3 error information:

https://developers.google.com/youtube/v3/docs/errors

"This error is commonly seen if you try to use the OAuth 2.0 Service Account flow. YouTube does not support Service Accounts, and if you attempt to authenticate using a Service Account, you will get this error."

Is this correct? I cannot use a service account to upload video to YouTube automatically?

(that was a waste of a couple of days hard work!)

like image 351
Claud Avatar asked Dec 13 '14 10:12

Claud


People also ask

Is YouTube Data API v3 free?

Yes, using the YouTube API does not incur any monetary cost for the entity calling the API. If you go over your quota an 403 Error will be returned by the API.

Can I allow others to upload to my YouTube channel?

Only the owner of the channel can upload videos to their YouTube account and they cannot delegate the task to someone else in the team.


1 Answers

Yes, it is correct.

The way forward is to do a manual authorisation and grab the resultant 'refresh token' and then use that for any automated uploads.

Ensure to add the refresh token to the PHP Google_Client object prior to any other action.

I am now automatically uploading to YouTube.

like image 117
Claud Avatar answered Sep 19 '22 18:09

Claud