title: 404 when getting Google Sheet via PHP API
body: <p>I am trying to pull in a Google Sheet via the <a href="https://github.com/google/google-api-php-client" rel="nofollow">PHP API Client</a>, but I am getting a 404 on a document that exists. Below is the error, a link to my spreadsheet, and my code. The file has been given edit permissions to my user, which is the user I used to setup the json credentials via the <a href="https://console.developers.google.com" rel="nofollow">Google Developers Console</a>. What am I missing?</p>
  
  <h2>Spreadsheet:</h2>
  
  <p><a href="https://docs.google.com/spreadsheets/d/1ZYa536OzU3aJs-jvxTDdKV9rGF9BiPLnKRp2wJL8va0/edit#gid=0" rel="nofollow">https://docs.google.com/spreadsheets/d/1ZYa536OzU3aJs-jvxTDdKV9rGF9BiPLnKRp2wJL8va0/edit#gid=0</a></p>
  
  <h2>Error:</h2>
  
  <pre><code>[15-Feb-2016 08:46:04 Europe/Berlin] PHP Fatal error:  Uncaught Google_Service_Exception: {
   "error": {
    "errors": [
     {
      "domain": "global",
      "reason": "notFound",
      "message": "File not found: 1ZYa536OzU3aJs-jvxTDdKV9rGF9BiPLnKRp2wJL8va0",
      "locationType": "other",
      "location": "file"
     }
    ],
    "code": 404,
    "message": "File not found: 1ZYa536OzU3aJs-jvxTDdKV9rGF9BiPLnKRp2wJL8va0"
   }
  }
   in /Applications/MAMP/htdocs/lp/vendor/google/apiclient/src/Google/Http/REST.php:129
  Stack trace:
  #0 /Applications/MAMP/htdocs/lp/vendor/google/apiclient/src/Google/Http/REST.php(88): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
  #1 /Applications/MAMP/htdocs/lp/vendor/google/apiclient/src/Google/Task/Runner.php(181): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
  #2 /Applications/MAMP/htdocs/lp/vendor/google/apiclient/src/Google/Http/REST.php(57): Google_Task_Runner-&gt;run()
  #3 /Applications/MAMP/htdocs/lp/vendor/google/a in /Applications/MAMP/htdocs/lp/vendor/google/apiclient/src/Google/Http/REST.php on line 129
  </code></pre>
  
  <h2>Code:</h2>
  
  <pre><code>&lt;?php
  require_once realpath(dirname(__FILE__) . '/vendor/autoload.php');
  include_once "google-api-php-client/examples/templates/base.php";
  $client = new Google_Client();
  putenv("GOOGLE_APPLICATION_CREDENTIALS=service-account-credentials.json");
  if ($credentials_file = checkServiceAccountCredentialsFile()) {
      $client-&gt;setAuthConfig($credentials_file);
  } elseif (getenv('GOOGLE_APPLICATION_CREDENTIALS')) {
    // use the application default credentials
    $client-&gt;useApplicationDefaultCredentials();
  } else {
    echo missingServiceAccountDetailsWarning();
    exit;
  }
  $client-&gt;setApplicationName("local-porch-1222");
  $client-&gt;setScopes(['https://www.googleapis.com/auth/drive','https://spreadsheets.google.com/feeds']);
  // The file ID was copied from a URL while editing the sheet in Chrome
  $fileId = '1ZYa536OzU3aJs-jvxTDdKV9rGF9BiPLnKRp2wJL8va0';
  // Access Token is used for Steps 2 and beyond
  $tokenArray = $client-&gt;fetchAccessTokenWithAssertion();
  $accessToken = $tokenArray["access_token"];
  // Section 1: Uncomment to get file metadata with the drive service
  // This is also the service that would be used to create a new spreadsheet file
  $service = new Google_Service_Drive($client);
  $results = $service-&gt;files-&gt;get($fileId);
  var_dump($results);
  ?&gt;
  </code></pre>