title: Google Calendar Events
body: <p>I am having some trouble adding events to Google Calendar. I can list events but when I try to add an event I am getting a 403 Forbidden Error. I am able to add events to primary, but when I try another one, in this case the one I've mnetion, I run into the 403 Forbidden Error. Here is the code I have:</p>
  
  <pre><code>require_once 'vendor/autoload.php';
  define('APPLICATION_NAME', 'Calendar');
  define('CREDENTIALS_PATH', 'credentials/calendar.json');
  define('SECRET_PATH', 'secret.json');
  define('SCOPES', implode(' ', array(Google_Service_Calendar::CALENDAR)));
  
  function getClient() {
      $client = new Google_Client();
      $client-&gt;setApplicationName(APPLICATION_NAME);
      $client-&gt;setScopes(SCOPES);
      $client-&gt;setAuthConfigFile(SECRET_PATH);
      $client-&gt;setAccessType('offline');
  
      $credentials_path = CREDENTIALS_PATH;
  
      if (file_exists($credentials_path)) {
          $access_token = file_get_contents($credentials_path);
      } else {
          // $auth_url = $client-&gt;createAuthUrl();
          // printf("Open the following link in your browser:\n%s\n", $auth_url);
  
          // print 'Enter verification code: ';
  
          // $auth_code = trim(fgets(STDIN));
  
          // $access_token = $client-&gt;authenticate($auth_code);
  
          // if (!file_exists(dirname($credentials_path))) {
              // mkdir(dirname($credentials_path), 0700, true);
          // }
  
          // file_put_contents($credentials_path, $access_token);
          // printf("Credentials saved to %s\n", $credentials_path);
  }
  
     $client-&gt;setAccessToken($access_token);
  
     if ($client-&gt;isAccessTokenExpired()) {
         $client-&gt;refreshToken($client-&gt;getRefreshToken());
         file_put_contents($credentials_path, $client-&gt;getAccessToken());
     }
  
     return $client; 
  
   }
  
  
  
     $client = getClient();
  
     $service = new Google_Service_Calendar($client);
  
  
     $event = new Google_Service_Calendar_Event();
     $event-&gt;setSummary('Appointment');
     $event-&gt;setLocation('Somewhere');
     $start = new Google_Service_Calendar_EventDateTime();
     $start-&gt;setDateTime('2015-04-14T10:00:00.000-07:00');
     $event-&gt;setStart($start);
     $end = new Google_Service_Calendar_EventDateTime();
     $end-&gt;setDateTime('2015-04-15T10:25:00.000-07:00');
     $event-&gt;setEnd($end);
     $attendee1 = new Google_Service_Calendar_EventAttendee();
     $attendee1-&gt;setEmail('leah@leahdawn.com');
  
     $attendees = array($attendee1);
     $event-&gt;attendees = $attendees;
     $createdEvent = $service-&gt;events-&gt;insert('leah@leahdawn.com', $event);
  
     echo $createdEvent-&gt;getId();
  </code></pre>
  
  <p>Specifically, the error is 'Error calling POST <a href="https://www.googleapis.com/calendar/v3/calendars/leah%40leahdawn.com/events" rel="nofollow">https://www.googleapis.com/calendar/v3/calendars/leah%40leahdawn.com/events</a>: (403) Forbidden.</p>
  
  <p>Any help would be appreciated!</p>