1
votes

After hours of searching, i've did'nt found a solution yet. The most relevant post i've found is : Youtube API : Service account

According to this part of the Google documentation : here

That i've read is that YT API did not support Service Accounts, so i've found no other solution yet.

There is any way to uploading videos to specific Google (YT) account, without ask the users of my service to log to their Google account ? The fact is that I want to any users on my website can upload some videos in private mode to my Youtube account, but google, when creating the client though this portion of code :

$client = new Google_Client();
$key = file_get_contents("some/path/to/".KEY_FILE);
$client->setClientId(CLIENT_ID);
     $client->setAssertionCredentials(
          new Google_AssertionCredentials(
              SERVICE_ACCOUNT_NAME,
              array('https://www.googleapis.com/auth/youtube'),
                $key
          )
     );
$client->setRedirectUri('some_url');
$client->setDeveloperKey('some_DEV_KEY');

request to my user to get logged in with his own Google account...

Any way to bypass this login request by enter my own credentials in the code ?

Sorry for not-so-good english, and thank you.

3

3 Answers

2
votes

Eric , It is possible to do that if you use the browser upload API ( V2 ) https://developers.google.com/youtube/2.0/developers_guide_protocol_browser_based_uploading . However it doesn't fully support CORS which means you can't show a progress bar and you must use iframes to handle the browser redirect. Youtube fixed the CORS issue in V3 but they don't support browser based uploading anymore so they suck and you have to choose either to proxy the video upload through your server(I do this) or ask the user login with their google account. I think they did it on purpose to promote the plus service. After they 'fixed it' ( took about a year ) a guy @jeff showed a demo using google plus to login ! what a joke !

0
votes

It is by design that you can't easily do what you're wanting; you don't want to be liable for what other people upload through your app into your account. The best way to accomplish what you're after is to use something like Youtube Direct Lite -- users will upload videos into their own accounts with their own credentials, but it automatically will tie those videos into a playlist that you run off your own app (and it even gives you review capabilities over whether those videos should be included).

You can also roll your own solution that accomplishes the same kind of approach. Trust me ... at some point you'll be grateful that you can't just let anyone upload into your personal account!

0
votes

Here's the solution : use ClientLogin authentication. That allow us to specify our YT credentials through this line :

$httpClient = Zend_Gdata_ClientLogin::getHttpClient($youtubeEmail, $youtubePassword, 'youtube');

NB : The third parameter is the "id" of the service we want to connect to

I know ClientLogin is deprecated but this solution work. If there is any solution more secure and clean, let me know :)

Have a nice day