title: Google Calendar API inserting event
body: <p>So, I downloaded this API library <a href="https://github.com/google/google-api-php-client.git" rel="nofollow">https://github.com/google/google-api-php-client.git</a>
  And installed it on server, then set up very simple script to add an event to my google calendar, first part of script makes sure your connection is good, second part tries to add event. So, connection is good, but adding event is not.. it gives me back </p>
  
  <pre><code>`Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling POST https://www.googleapis.com/calendar/v3/calendars/primary/events: (403) Insufficient Permission'` 
  </code></pre>
  
  <p>here is the script, can someone help? </p>
  
  <pre><code>&lt;?php
  session_start();        
  require '../google-api-php-client-master/src/Google/autoload.php';
  require_once '../google-api-php-client-master/src/Google/Client.php';
  require_once '../google-api-php-client-master/src/Google/Service/Calendar.php';     
  
  $client_id = '574154490008-l55646vdpf62f7nrim9dodhtg6ssv4qv.apps.googleusercontent.com';
  $Email_address = '574154490008-l55646vdpf62f7nrim9dodhtg6ssv4qv@developer.gserviceaccount.com';  
  $key_file_location = 'someproject-9e09f9db466c.p12';        
  $client = new Google_Client();      
  $client-&gt;setApplicationName("Client_Library_Examples");
  $key = file_get_contents($key_file_location);
  
  // seproate 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();
  print_r($calendarList);
  while(true) {
      foreach ($calendarList-&gt;getItems() as $calendarListEntry) {
          echo "&lt;a href='Oauth2.php?type=event&amp;id=".$calendarListEntry-&gt;id." '&gt;".$calendarListEntry-&gt;getSummary()."&lt;/a&gt;&lt;br&gt;\n";
      }
      $pageToken = $calendarList-&gt;getNextPageToken();
      if ($pageToken) {
          $optParams = array('pageToken' =&gt; $pageToken);
          $calendarList = $service-&gt;calendarList-&gt;listCalendarList($optParams);
      } else {
          break;
      }
  }    
  
      //--------------- trying to insert EVENT
  
      $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-16T10:00:00.000-07:00');
      $event-&gt;setStart($start);
      $end = new Google_Service_Calendar_EventDateTime();
      $end-&gt;setDateTime('2015-04-16T10:25:00.000-07:00');
      $event-&gt;setEnd($end);
      $attendee1 = new Google_Service_Calendar_EventAttendee();
      $attendee1-&gt;setEmail('some@gmail.com');
      // ...
      $attendees = array($attendee1
                     //, ...
                    );
      $event-&gt;attendees = $attendees;
      $createdEvent = $service-&gt;events-&gt;insert('primary', $event);
      echo $createdEvent-&gt;getId();
  
  
  
  ?&gt;
  &lt;/html&gt;  
  </code></pre>
  
  <p>Ok, So I just edited this line <code>$scopes ="https://www.googleapis.com/auth/calendar";</code> I deleted ".readonly" so now I am getting eventId back as if I was inserting events successfully, but events are not showing up in the calendar.</p>