title: Insert Event in Google Calendar With Javascript
body: <p>My client ID is correct but hidden in this example. </p>
  
  <p>I need help posting an event to my calendar. I believe I have the code correct but I need someone else's eyes.</p>
  
  <p>I just need to post a event to the calendar.</p>
  
  <pre><code>SCOPES = ["https://www.googleapis.com/auth/calendar"]
  function checkAuth() {
      gapi.auth.authorize(
        {
          'client_id': CLIENT_ID,
          'scope': SCOPES.join(' '),
          'immediate': true
        }, handleAuthResult);
    }
  
    /**
     * Handle response from authorization server.
     *
     * @param {Object} authResult Authorization result.
     */
    function handleAuthResult(authResult) {
      var authorizeDiv = document.getElementById('authorize-div');
      if (authResult &amp;&amp; !authResult.error) {
        // Hide auth UI, then load client library.
        authorizeDiv.style.display = 'none';
        loadCalendarApi();
      } else {
        // Show auth UI, allowing the user to initiate authorization by
        // clicking authorize button.
        authorizeDiv.style.display = 'inline';
      }
    }
  
    /**
     * Initiate auth flow in response to user clicking authorize button.
     *
     * @param {Event} event Button click event.
     */
    function handleAuthClick(event) {
      gapi.auth.authorize(
        {client_id: CLIENT_ID, scope: SCOPES, immediate: false},
        handleAuthResult);
      return false;
    }
  
    /**
     * Load Google Calendar client library. List upcoming events
     * once client library is loaded.
     */
    function loadCalendarApi() {
      gapi.client.load('calendar', 'v3', listUpcomingEvents);
    }
  
    /**
     * Print the summary and start datetime/date of the next ten events in
     * the authorized user's calendar. If no events are found an
     * appropriate message is printed.
     */
    function listUpcomingEvents() {
      var event = {
  "summary":"Here"
  "description":"Now"
  "start":
  {
  "dateTime":"2016-04-21T12:00:00.000-07:00"
  "timeZone":"America/Los_Angeles"
  }
  "end":
  {
  "dateTime":"2016-04-21T12:30:00.000-07:00"
  "timeZone":"America/Los_Angeles"
  }
  };
  var request = gapi.client.calendar.events.insert({
  'calendarId': 'primary',
  'resource': event
  });
  
  request.execute(function(event) {
  appendPre('Event created: ' + event.htmlLink);
  }); 
    }
  </code></pre>