title: How to create a spreadsheet with google api and set a proper permissions with PHP?
body: <p>I have this </p>
  
  <pre><code>define('CLIENT_SECRET_PATH', __DIR__ . '/config_api.json');
  define('ACCESS_TOKEN', '0b502651********c52b3');
  </code></pre>
  
  <p>I can create a spreadsheet with this and get the id and url.</p>
  
  <pre><code>$requestBody = new Google_Service_Sheets_Spreadsheet();
  $response = $service-&gt;spreadsheets-&gt;create($requestBody);
  print_r($response);
  $new_spr_id = $response['spreadsheetId'];
  </code></pre>
  
  <p>But this spreadsheet does not appears in the google sheets list as it is "<strong>protected</strong>" or something.
  I am trying to set the permissions with this but get an error: <strong>Fatal error:</strong> Call to undefined method Google_Service_Drive_Permission::setValue()</p>
  
  <pre><code>insertPermission($service, $new_spr_id, '**@gmail.com' , 'user', 'owner');
  function insertPermission($service, $fileId, $value, $type, $role) {
    $newPermission = new Google_Service_Drive_Permission();
    $newPermission-&gt;setValue($value);
    $newPermission-&gt;setType($type);
    $newPermission-&gt;setRole($role);
    try {
      return $service-&gt;permissions-&gt;insert($fileId, $newPermission);
    } catch (Exception $e) {
      print "An error occurred: " . $e-&gt;getMessage();
    }
    return NULL;
  }
  </code></pre>
  
  <p>I need an example of creating a new spreadsheet and setting the proper permissions to it so I can modify this spreadsheet from my account etc.</p>
  
  <p>Many many thanks!</p>