title: Error 404 when accessing a file via a Service Account
body: <p>I have to read an excel file on google drive. I need to connect automatically to google drive without prompt any form... a bot must read document... I have this code:</p>
  
  <pre><code>$service_account_file = dirname(__FILE__) . '/key-85ac95ab1e62.json';
  $spreadsheet_id = 'the_id_inside_the_url_of_the_file';
  
  $spreadsheet_range = 'Sheet1!A1:A1';
  putenv('GOOGLE_APPLICATION_CREDENTIALS=' . $service_account_file);
  $client = new Google_Client();
  $client-&gt;useApplicationDefaultCredentials();
  $client-&gt;addScope(Google_Service_Sheets::SPREADSHEETS);
  $service = new Google_Service_Sheets($client);
  $result = $service-&gt;spreadsheets_values-&gt;get($spreadsheet_id, $spreadsheet_range);
  var_dump($result-&gt;getValues());
  </code></pre>
  
  <p>Something goes wrong... I explain how I generated the <code>key-*.json</code> file:</p>
  
  <p>On <code>Google Console Developer</code> i clicked on Service Account, then i created a new one and downloaded the json.. this json is the <code>key-*.json</code> file. I have added this file in my project (as you can see on first row)... Here i copied the <code>Account Service Id</code>that I will use later...</p>
  
  <p>Now I explain how I get the <code>spreadheet_id</code>... I went on my google drive, right click on the file and I shared it with the <code>Account Service Id</code> (copied before) and an url has been generated... if I copy and past the url in the browser everything works but not in the project... i take the spreadsheet_id from url</p>
  
  <p>this is the error I receive :</p>
  
  <pre><code>PHP Fatal error:  Uncaught Google_Service_Exception: {
    "error": {
      "code": 404,
      "message": "Requested entity was not found.",
      "errors": [
        {
          "message": "Requested entity was not found.",
          "domain": "global",
          "reason": "notFound
        }
      ],
      "status": "NOT_FOUND
    }
  }
  </code></pre>
  
  <p>What's wrong? the file exists and i cann see it in the browser using the same url I use in the php file... so I think it is a connection or login problem...</p>
  
  <p>any idea?</p>