title: Error in File Upload using google Drive API
body: <p>I'm trying to Upload file to the Google Drive using php.
  I'm not able to authenticate to google. 
  I have generated client_secret.json. as per their suggestion. 
  But I don't know what is drive-php-quickstart.json here.</p>
  
  <p>I have follow this link :- <a href="https://developers.google.com/drive/v3/web/quickstart/php" rel="nofollow noreferrer">https://developers.google.com/drive/v3/web/quickstart/php</a>.</p>
  
  <p>I have cloned git's google repository from here 
  Link :- <a href="https://github.com/google/google-api-php-client" rel="nofollow noreferrer">https://github.com/google/google-api-php-client</a>.
  And I have make one file quickstart.php in the root folder but nothing happens and in console it shows.</p>
  
  <p>I have Tried below code.</p>
  
  <pre><code>&lt;?php
  require_once __DIR__ . '/vendor/autoload.php';
  
  
  define('APPLICATION_NAME', 'Drive API PHP Quickstart');
  define('CREDENTIALS_PATH', '~/.credentials/drive-php-quickstart.json');
  define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json');
  // If modifying these scopes, delete your previously saved credentials
  // at ~/.credentials/drive-php-quickstart.json
  define('SCOPES', implode(' ', array(
    Google_Service_Drive::DRIVE_METADATA_READONLY)
  ));
  
  if (php_sapi_name() != 'cli') {
    throw new Exception('This application must be run on the command line.');
  }
  
  /**
   * Returns an authorized API client.
   * @return Google_Client the authorized client object
   */
  function getClient() {
    $client = new Google_Client();
    $client-&gt;setApplicationName(APPLICATION_NAME);
    $client-&gt;setScopes(SCOPES);
    $client-&gt;setAuthConfig(CLIENT_SECRET_PATH);
    $client-&gt;setAccessType('offline');
  
    // Load previously authorized credentials from a file.
    $credentialsPath = expandHomeDirectory(CREDENTIALS_PATH);
    if (file_exists($credentialsPath)) {
      $accessToken = json_decode(file_get_contents($credentialsPath), true);
    } else {
      // Request authorization from the user.
      $authUrl = $client-&gt;createAuthUrl();
      printf("Open the following link in your browser:\n%s\n", $authUrl);
      print 'Enter verification code: ';
      $authCode = trim(fgets(STDIN));
  
      // Exchange authorization code for an access token.
      $accessToken = $client-&gt;fetchAccessTokenWithAuthCode($authCode);
  
      // Store the credentials to disk.
      if(!file_exists(dirname($credentialsPath))) {
        mkdir(dirname($credentialsPath), 0700, true);
      }
      file_put_contents($credentialsPath, json_encode($accessToken));
      printf("Credentials saved to %s\n", $credentialsPath);
    }
    $client-&gt;setAccessToken($accessToken);
  
    // Refresh the token if it's expired.
    if ($client-&gt;isAccessTokenExpired()) {
      $client-&gt;fetchAccessTokenWithRefreshToken($client-&gt;getRefreshToken());
      file_put_contents($credentialsPath, json_encode($client-&gt;getAccessToken()));
    }
    return $client;
  }
  
  /**
   * Expands the home directory alias '~' to the full path.
   * @param string $path the path to expand.
   * @return string the expanded path.
   */
  function expandHomeDirectory($path) {
    $homeDirectory = getenv('HOME');
    if (empty($homeDirectory)) {
      $homeDirectory = getenv('HOMEDRIVE') . getenv('HOMEPATH');
    }
    return str_replace('~', realpath($homeDirectory), $path);
  }
  
  // Get the API client and construct the service object.
  $client = getClient();
  $service = new Google_Service_Drive($client);
  
  // Print the names and IDs for up to 10 files.
  $optParams = array(
    'pageSize' =&gt; 10,
    'fields' =&gt; 'nextPageToken, files(id, name)'
  );
  $results = $service-&gt;files-&gt;listFiles($optParams);
  
  if (count($results-&gt;getFiles()) == 0) {
    print "No files found.\n";
  } else {
    print "Files:\n";
    foreach ($results-&gt;getFiles() as $file) {
      printf("%s (%s)\n", $file-&gt;getName(), $file-&gt;getId());
    }
  }
  </code></pre>
  
  <p>Please suggest me what is I'm missing.</p>