title: Create Playlist without End-User auth - YouTube API v3
body: <p>I am trying to figure out a way to create playlists, upload videos, and so on without having the user authentication themselves, but instead having the server do it for them using my YouTube account.</p>
  
  <p>I started off by just doing a channel list adding the <code>mine</code> parameter since that requires authentication.</p>
  
  <p>Here's the code I used and results can be seen at <a href="http://www.daysofthedead.net/testing/playlist.php" rel="nofollow">http://www.daysofthedead.net/testing/playlist.php</a></p>
  
  <p>You can see at the bottom the code works because I can pull the results from a search which doesn't require authentication. But the channel list is empty, which does require authentication.</p>
  
  <pre><code>&lt;?php
  require_once 'GoogleClient/Google_Client.php';
  require_once 'GoogleClient/contrib/Google_YoutubeService.php';
  
  // Set your client id, service account name, and the path to your private key.
  // For more information about obtaining these keys, visit:
  // https://developers.google.com/console/help/#service_accounts
  const CLIENT_ID = 'xxxxxxxxxx.apps.googleusercontent.com';
  const SERVICE_ACCOUNT_NAME = 'xxxxxxxxxx8@developer.gserviceaccount.com';
  
  // Make sure you keep your key.p12 file in a secure location, and isn't
  // readable by others.
  const KEY_FILE = 'xxxxxxxxxx-privatekey.p12';
  
  $client = new Google_Client();
  $client-&gt;setApplicationName("Google YouTube Sample");
  
  // Set your cached access token. Remember to replace $_SESSION with a
  // real database or memcached.
  session_start();
  if (isset($_SESSION['token'])) {
   $client-&gt;setAccessToken($_SESSION['token']);
  }
  
  // Load the key in PKCS 12 format (you need to download this from the
  // Google API Console when the service account was created.
  $key = file_get_contents(KEY_FILE);
  $client-&gt;setAssertionCredentials(new Google_AssertionCredentials(
      SERVICE_ACCOUNT_NAME,
      array('https://www.googleapis.com/auth/youtube'),
      $key)
  );
  
  $client-&gt;setClientId(CLIENT_ID);
  $service = new Google_YouTubeService($client);
  
  # User to search Youtube for.
  $search_user = "BruceLeeOfficialPage";
  
  # listSearch optional parameters
  $search_optParams = array('part' =&gt; 'snippet', 'q' =&gt; $search_user, 'maxResults' =&gt; 2, 'type' =&gt; 'video');
  # Search YouTube
  $search = $service-&gt;search-&gt;listSearch($search_optParams);
  
  # listChannels optional parameters.
  $channel_optParams = array('maxResults' =&gt; 50, 'mine' =&gt; 'true');
  # Get YouTube user's channel information
  $channel = $service-&gt;channels-&gt;listChannels('snippet', $channel_optParams);
  
  // We're not done yet. Remember to update the cached access token.
  // Remember to replace $_SESSION with a real database or memcached.
  if ($client-&gt;getAccessToken()) {
    $_SESSION['token'] = $client-&gt;getAccessToken();
  }
  ?&gt;
  &lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;link rel='stylesheet' href='style.css' /&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;header&gt;&lt;h1&gt;YouTube API v3 Sample App&lt;/h1&gt;&lt;/header&gt;
  &lt;div class="box"&gt;
  
  &lt;?php if(isset($search)): ?&gt;
  &lt;div class="search"&gt;&lt;H1&gt;Search:&lt;/H1&gt;
  &lt;pre&gt;&lt;?php print_r($search); ?&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;?php endif ?&gt;
  
  &lt;?php if(isset($channel)): ?&gt;
  &lt;div class="channel"&gt;&lt;H1&gt;Channel:&lt;/H1&gt;
  &lt;pre&gt;&lt;?php print_r($channel); ?&gt;&lt;/pre&gt;&lt;/div&gt;
  &lt;?php endif ?&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Anyone able to help me out with this? Is there some kind of work around? Code examples would be extremely grateful. Thank you.</p>