title: Unable to transfer ownership of file from service account to google drive user
body: <p>When attempting to transfer ownership I get the following error:</p>
  <pre><code>&quot;domain&quot;: &quot;global&quot;,
  &quot;reason&quot;: &quot;invalidSharingRequest&quot;,
  &quot;message&quot;: &quot;Bad Request. User message: \&quot;You can't change the owner of this item.\&quot;&quot;
  </code></pre>
  <p>Here is my code:</p>
  <pre><code>use Google_Client; 
  use Google_Service_Drive;
  use Google_Service_Drive_DriveFile;
  use Google_Service_Drive_Permission;
  
  public function uploadDocument() {
  
   $FOLDER_ID = 'my_folder_ID_string';
  
   $client = new Google_Client();
   $client-&gt;setAuthConfig(base_path('service_account_credentials.json'));
   $client-&gt;setScopes(array('https://www.googleapis.com/auth/drive'));
  
   $service = new Google_Service_Drive($client);
  
   $fileMetadata = new Google_Service_Drive_DriveFile(array(
                                                       'name' =&gt; 'Test.pdf',
                                                       'parents' =&gt; [$FOLDER_ID]
                                                      ));
  
   $content = file_get_contents(public_path('tmp/Test.pdf'));
  
   $file = $service-&gt;files-&gt;create($fileMetadata, array(
                                                      'data' =&gt; $content,
                                                      'mimeType' =&gt; 'application/pdf',
                                                      'uploadType' =&gt; 'multipart',
                                                      'fields' =&gt; 'id'
                                                       ));
  
    // Transfer Ownership
    $newPermission = new Google_Service_Drive_Permission();
    $newPermission-&gt;setRole('owner');
    $newPermission-&gt;setType('user');
    $newPermission-&gt;setEmailAddress('email@gmail.com');
    $optParams = array('transferOwnership' =&gt; 'true');
  
    $service-&gt;permissions-&gt;create($file-&gt;id, $newPermission, $optParams);
  
  }
  </code></pre>
  <p>The folder is successfully uploaded to Google Drive in the shared folder (owner is 'email@gmail.com', service account is 'editor'), however the owner of the uploaded file is the service account and the editor is 'email@gmail.com'.</p>