2

My main question is: can I use the access token got from service account to upload a video to youtube?

Account is new, connected to youtube, channel is created got the access token in the following mode:

$client = new Google_Client();
$client->setApplicationName('Youtube Login');

$key = file_get_contents($key_file);

$client->setClientId($client_id);
$client->setAssertionCredentials(new Google_AssertionCredentials(
   $service_account_name,
   array(
      'https://www.googleapis.com/auth/youtube.upload',
      'https://www.googleapis.com/auth/youtube'
      'https://gdata.youtube.com/action/GetUploadToken',
      'https://gdata.youtube.com'
   ),
   $key)
);

$client::$auth->refreshTokenWithAssertion();
$json = $client->getAccessToken();
$accessToken = json_decode($json)->access_token;

So the access token is ok. Now when I create the header and insert the access token and developer key and everything needed described here: https://developers.google.com/youtube/2.0/developers_guide_protocol_browser_based_uploading I get NoLinkedYouTubeAccount error.

If a Service Account cannot be used to upload a video this way, is there a way to skip user interaction in video upload?

We have the account, but we do not want users to be redirected anywhere just because ClientLogin is deprecated and Youtube API v2.0 does not support OAuth2 Service Account access token.

Is there a way? Searched all over the net, saw similar unanswered questions, but got nowhere.

rodrigo-silveira
  • 12,607
  • 11
  • 69
  • 123

1 Answers1

1

You cannot use a service account to accomplish this: https://code.google.com/p/google-api-php-client/wiki/OAuth2?hl=de-DE#Service_Accounts I too am looking for a way to perform youtube api calls without end user authentication. How do you recieve an access token without user intervention for a known account using Google Youtube API v3?

Community
  • 1
  • 1
Bil1
  • 440
  • 2
  • 18