title: Google Calendar API v3 - Google_AuthException - Could not json decode the token issue
body: <p>I've searched this Group, plus others, along with other websites and cannot find a solution to this. Error output is below. I definitely know that setAccessToken should NOT be NULL. Any guidance would be great here. the Google Calendar v3 API documentation is not so great...in fact, the samples are for older API versions.</p>
  
  <p>PHP Fatal error:  Uncaught exception 'Google_AuthException' with message 'Could not json decode the token' in google-api-php-client/src/auth/Google_OAuth2.php:162
  Stack trace:</p>
  
  <p>0 google-api-php-client/src/Google_Client.php(170): Google_OAuth2->setAccessToken(NULL)</p>
  
  <p>1 Cal.php(16): Google_Client->setAccessToken(true)</p>
  
  <p>2 {main}
    thrown in google-api-php-client/src/auth/Google_OAuth2.php on line 162</p>
  
  <p>Below is the code for my app:</p>
  
  <pre><code>&lt;?php
  require_once 'google-api-php-client/src/Google_Client.php';
  require_once 'google-api-php-client/src/contrib/Google_CalendarService.php';
  session_start();
  $client = new Google_Client();
  $service = new Google_CalendarService($client);
  if (isset($_REQUEST['logout'])) {
    unset($_SESSION['token']);
  }
  if (isset($_SESSION['token'])) {
    $client-&gt;setAccessToken($_SESSION['token']);
  } else {
    $client-&gt;setAccessToken($client-&gt;authenticate($_GET['code']));
    $_SESSION['token'] = $client-&gt;getAccessToken();
  }
  if (isset($_SESSION['token'])) {
    $client-&gt;setAccessToken($_SESSION['token']);
  }
  if ($client-&gt;getAccessToken()) { 
  $event = new Google_Event();
  $event-&gt;setSummary('Appointment');
  $event-&gt;setLocation('Somewhere');
  $start = new Google_EventDateTime();
  $start-&gt;setDateTime('2013-10-05T10:00:00.000-07:00');
  $event-&gt;setStart($start);
  $end = new Google_EventDateTime();
  $end-&gt;setDateTime('2013-10-05T10:25:00.000-07:00');
  $event-&gt;setEnd($end);
  $attendee1 = new Google_EventAttendee();
  $attendee1-&gt;setEmail('my@email.com');
  // ...
  $attendees = array($attendee1);
  $event-&gt;attendees = $attendees;
  $createdEvent = $service-&gt;events-&gt;insert('primary', $event);
  echo $createdEvent-&gt;getId();
  } else {
  echo "failed hard";
  }
  ?&gt;
  </code></pre>
  
  <p>ClientID, Key, etc are kept in my google-api-php-client/src/config.php file</p>