title: How do I read a Google Drive Spreadsheet in PHP?
body: <p>All I'm trying to do is read a Google Spreadsheet from a web site. I've read and re-read the Google Drive API docs and everything Google Drive PHP on Stack Overflow and I still can't get to the end zone.</p>
  
  <p>Here's what I've done :</p>
  
  <ol>
  <li>Been to the Google APIs Console and :
  <ol>
  <li>Enabled "Drive API" and "Drive SDK" under 'Services';</li>
  <li>Created an OAuth 2.0 client ID under 'API Access'. Under "Client ID for web applications", the console gave me "Client ID", "Email address", "Client secret", "Redirect URIs" and "JavaScript origins";</li>
  </ol></li>
  <li>Downloaded the "Google API PHP Client Library";</li>
  <li>Opened the Google Drive document (spreadsheet) and clicked on "Share" to get the document's 'key';</li>
  <li>Set up the following code :</li>
  </ol>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php 
  session_start(); 
  require_once 'lib/gapi/Google_Client.php'; 
  require_once 'lib/gapi/contrib/Google_DriveService.php'; 
  
  define( 'GDRIVE_CLIENT_ID', '&lt;API Console - API Access - Client ID&gt;' ); 
  define( 'GDRIVE_CLIENT_SECRET', '&lt;API Console - API Access - Client secret&gt;' ); 
  define( 'GDRIVE_REDIRECT_URIS', '&lt;API Console - API Access - Redirect URIs&gt;' ); 
  
  define( 'GDRIVE_SCOPE_01', 'h t t p s://www.googleapis.com/auth/drive' ); 
  define( 'GDRIVE_SCOPE_02', 'h t t p s://www.googleapis.com/auth/drive.apps.readonly' ); 
  define( 'GDRIVE_SCOPE_03', 'h t t p s://www.googleapis.com/auth/drive.file' ); 
  define( 'GDRIVE_SCOPE_04', 'h t t p s://www.googleapis.com/auth/drive.metadata.readonly' ); 
  define( 'GDRIVE_SCOPE_05', 'h t t p s://www.googleapis.com/auth/drive.readonly' ); 
  define( 'GDRIVE_FILE_KEY', '&lt;'key' given from 'sharing' document&gt;' ); 
  
  $client = new Google_Client(); 
  $client-&gt;setClientId( GDRIVE_CLIENT_ID ); 
  $client-&gt;setClientSecret( GDRIVE_CLIENT_SECRET ); 
  $client-&gt;setRedirectUri( GDRIVE_REDIRECT_URIS ); 
  $client-&gt;setScopes( array( GDRIVE_SCOPE_01, GDRIVE_SCOPE_02, GDRIVE_SCOPE_03, GDRIVE_SCOPE_04, GDRIVE_SCOPE_05 ) ); 
  
  try { 
    $file = $service-&gt;files-&gt;get( GDRIVE_FILE_KEY ); 
    echo "Title: ", $file-&gt;getTitle(); 
    echo "Description: ", $file-&gt;getDescription(); 
    echo "MIME type: ", $file-&gt;getMimeType(); 
  } catch (Exception $e) { 
    echo "An error occurred: ", $e-&gt;getMessage(); 
  } 
  ?&gt; 
  </code></pre>
  
  <p>All runs fine (no errors anyway) until the <code>$service-&gt;files-&gt;get( GDRIVE_FILE_KEY )</code> call which triggers the exception:</p>
  
  <blockquote>
    <p>An error occurred: Error calling GET <code>https://www.googleapis.com/drive/v2/files</code>: (403) Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.</p>
  </blockquote>
  
  <p>What am I doing wrong? I've pulled my hair out (well, what was left).</p>