title: Google API error
body: <p>I am trying to use google API to get events off calendars on an account. I am using a service account. I am receiving two errors when I attempt to manually echo the code or it will remain a blank page if I use foreach(...).
  Here are the two errors:</p>
  
  <pre><code> Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/calendar/v3/users/me/calendarList/primary: (404) Not Found' in C:\wamp\www\newOLP\scripts\oAuth2\Google\Http\REST.php on line 110
  ( ! ) Google_Service_Exception: Error calling GET https://www.googleapis.com/calendar/v3/users/me/calendarList/primary: (404) Not Found in C:\wamp\www\newOLP\scripts\oAuth2\Google\Http\REST.php on line 110
  </code></pre>
  
  <p>Here is my code: </p>
  
  <pre><code>require_once 'Google/autoload.php';
     session_start();     
  /************************************************   
   The following 3 values an befound in the setting   
   for the application you created on Google      
   Developers console.         Developers console.
   The Key file should be placed in a location     
   that is not accessable from the web. outside of 
   web root.   
  
   In order to access your GA account you must    
   Add the Email address as a user at the     
   ACCOUNT Level in the GA admin.         
   ************************************************/
  $client_id = $jsonDecode['client_id'];
      $Email_address = $jsonDecode['client_email'];    
      $key_file_location = 'privateKey.p12';      
  
      $client = new Google_Client();      
      $client-&gt;setApplicationName("CalCon");
      $key = file_get_contents($key_file_location);    
  
  // separate additional scopes with a comma   
  $scopes ="https://www.googleapis.com/auth/calendar.readonly";   
  $cred = new Google_Auth_AssertionCredentials(    
      $Email_address,      
      array($scopes),     
      $key         
      );      
  $client-&gt;setAssertionCredentials($cred);
  if($client-&gt;getAuth()-&gt;isAccessTokenExpired()) {        
      $client-&gt;getAuth()-&gt;refreshTokenWithAssertion($cred);       
  }       
  $service = new Google_Service_Calendar($client);    
  
  ?&gt;
  
  &lt;html&gt;&lt;body&gt;
  
  &lt;?php
  $calendarList  = $service-&gt;calendarList-&gt;listCalendarList();
  echo $service-&gt;calendars-&gt;get('primary')-&gt;getSummary()."&lt;br /&gt;";
  echo $service-&gt;calendarList-&gt;get('primary')-&gt;getSummary();
  while(true) {
      foreach ($calendarList-&gt;getItems() as $calendarListEntry) {
              echo $calendarListEntry;
              echo "hi";
              echo $calendarListEntry-&gt;getSummary()."&lt;br&gt;\n";
  
  
              // get events 
              $events = $service-&gt;events-&gt;listEvents($calendarListEntry-&gt;id);
  
  
              foreach ($events-&gt;getItems() as $event) {
                  echo "-----".$event-&gt;getSummary()."&lt;br&gt;";
              }
          }
          $pageToken = $calendarList-&gt;getNextPageToken();
          if ($pageToken) {
              $optParams = array('pageToken' =&gt; $pageToken);
              $calendarList = $service-&gt;calendarList-&gt;listCalendarList($optParams);
          } else {
              break;
          }
      }
  
  ?&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>