title: Insert file Google drive wget
body: <p>I have a script from Google drive and wordks fine when i executing by browser, but i want to execute it by Wget, but that doesn't work.
  Why does this not work with wget?</p>
  
  <pre><code>$client = new Google_Client();
  $client-&gt;setAuthConfig($oauth_credentials);
  $client-&gt;setRedirectUri($redirect_uri);
  $client-&gt;addScope("https://www.googleapis.com/auth/drive");
  $service = new Google_Service_Drive($client);
  
  if (!empty($_SESSION['upload_token'])) {
    $client-&gt;setAccessToken($_SESSION['upload_token']);
    if ($client-&gt;isAccessTokenExpired()) {
      unset($_SESSION['upload_token']);
    }
  }
  else {
    $authUrl = $client-&gt;createAuthUrl();
  }
  
  DEFINE("TESTFILE", 'testfile-small.txt');
  
  if (!file_exists(TESTFILE)) {
    $fh = fopen(TESTFILE, 'w');
    fseek($fh, 1024 * 1024);
    fwrite($fh, "!", 1);
    fclose($fh);
  }
  
  // This is uploading a file directly, with no metadata associated.
  $file = new Google_Service_Drive_DriveFile();
  
  $result = $service-&gt;files-&gt;insert(
    $file,
    array(
      'data' =&gt; file_get_contents(TESTFILE),
      'mimeType' =&gt; 'application/octet-stream',
      'uploadType' =&gt; 'media'
    )
  );
  </code></pre>