title: google drive PHP permission
body: <p>I am want to share permission on some folders on google drive, with help google service account, but Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling POST <a href="https://www.googleapis.com/drive/v2/files/0ByXNGBI2AHyZX0RZd2pROE5qNFk/permissions" rel="nofollow">https://www.googleapis.com/drive/v2/files/0ByXNGBI2AHyZX0RZd2pROE5qNFk/permissions</a>: (500) Internal Error' 
  Its problem has been only when use Service Account type authentication</p>
  
  <p>when i am paste more scopes<code>array('https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/drive.file'),</code>  i recive 404 error File not found 0ByXNGBI2AHyZX0RZd2pROE5qNFk</p>
  
  <pre><code> &lt;?php
  session_start();
  include_once "templates/base.php";
  
  /************************************************
  Make an API request authenticated with a service
  account.
   ************************************************/
  set_include_path("../src/" . PATH_SEPARATOR . get_include_path());
  require_once 'Google/Client.php';
  require_once 'Google/Service/Drive.php';
  
  $client_id = '1077677978854-deaidfbbb36erpstbjsvqh6s1iftg36k.apps.googleusercontent.com';
  $service_account_name = '1077677978854-deaidfbbb36erpstbjsvqh6s1iftg36k@developer.gserviceaccount.com';
  $key_file_location = './8c320ff616a77aec2421642de64449dad6f4a9ca-privatekey.p12';
  
  $client = new Google_Client();
  
  if (isset($_SESSION['service_token'])) {
      $client-&gt;setAccessToken($_SESSION['service_token']);
  }
  $key = file_get_contents($key_file_location);
  $cred = new Google_Auth_AssertionCredentials(
      $service_account_name,
      array('https://www.googleapis.com/auth/drive'),
      $key
  );
  $client-&gt;setAssertionCredentials($cred);
  if($client-&gt;getAuth()-&gt;isAccessTokenExpired()) {
      $client-&gt;getAuth()-&gt;refreshTokenWithAssertion($cred);
  }
  $_SESSION['service_token'] = $client-&gt;getAccessToken();
  var_dump($client);
  $service = new Google_Service_Drive($client);
  $newPermission= new Google_Service_Drive_Permission();
  $newPermission-&gt;setType('user');
  $newPermission-&gt;setRole('reader');
  $newPermission-&gt;setValue('rizr19911006@gmail.com'); //thats email to share
  $service-&gt;permissions-&gt;insert('0ByXNGBI2AHyZX0RZd2pROE5qNFk',$newPermission);
  </code></pre>