title: API Google Calendar Not work
body: <p>I'm trying to use the Google Calendar API without success.
  I'm following the tuto:</p>
  
  <p><a href="https://developers.google.com/google-apps/calendar/quickstart/js" rel="nofollow noreferrer">https://developers.google.com/google-apps/calendar/quickstart/js</a></p>
  
  <p>But it doesn't work I have an error message:</p>
  
  <blockquote>
    <p>Error response </p>
    
    <p>Error code 404. </p>
    
    <p>Message: File not found. </p>
    
    <p>Error code explanation: 404 = Nothing matches the given URI.</p>
  </blockquote>
  
  <p>Yet I'm following the steps. I post you the complete code because I have a slight doubt about the end of the script. Having already used the Outlook API, which is full of errors, I am suspicious.
  If I copy/paste their script my IDE detects an error, I modified it, but I have doubts.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt; nodal-algebra-193713 &lt;/title&gt;
      &lt;meta charset='utf-8' /&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;p&gt; nodal-algebra-193713 &lt;/p&gt;
  
      &lt;!--Add buttons to initiate auth sequence and sign out--&gt;
      &lt;button id="authorize-button" style="display:"&gt;Authorize&lt;/button&gt;
      &lt;button id="signout-button" style="display: "&gt;Sign Out&lt;/button&gt;
  
      &lt;pre id="content"&gt;&lt;/pre&gt;
  
      &lt;script type="text/javascript"&gt;
        // Client ID and API key from the Developer Console
        var CLIENT_ID = '***********';
        var API_KEY = '************';
  
        // Array of API discovery doc URLs for APIs used by the quickstart
        var DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"];
  
        // Authorization scopes required by the API; multiple scopes can be
        // included, separated by spaces.
        var SCOPES = "https://www.googleapis.com/auth/calendar.readonly";
  
        var authorizeButton = document.getElementById('authorize-button');
        var signoutButton = document.getElementById('signout-button');
  
        /**
         *  On load, called to load the auth2 library and API client library.
         */
        function handleClientLoad() {
          gapi.load('client:auth2', initClient);
        }
  
        /**
         *  Initializes the API client library and sets up sign-in state
         *  listeners.
         */
        function initClient() {
          gapi.client.init({
            apiKey: API_KEY,
            clientId: CLIENT_ID,
            discoveryDocs: DISCOVERY_DOCS,
            scope: SCOPES
          }).then(function () {
            // Listen for sign-in state changes.
            gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
  
            // Handle the initial sign-in state.
            updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
            authorizeButton.onclick = handleAuthClick;
            signoutButton.onclick = handleSignoutClick;
          });
        }
  
        /**
         *  Called when the signed in status changes, to update the UI
         *  appropriately. After a sign-in, the API is called.
         */
        function updateSigninStatus(isSignedIn) {
          if (isSignedIn) {
            authorizeButton.style.display = 'none';
            signoutButton.style.display = 'block';
            listUpcomingEvents();
          } else {
            authorizeButton.style.display = 'block';
            signoutButton.style.display = 'none';
          }
        }
  
        /**
         *  Sign in the user upon button click.
         */
        function handleAuthClick(event) {
          gapi.auth2.getAuthInstance().signIn();
        }
  
        /**
         *  Sign out the user upon button click.
         */
        function handleSignoutClick(event) {
          gapi.auth2.getAuthInstance().signOut();
        }
  
        /**
         * Append a pre element to the body containing the given message
         * as its text node. Used to display the results of the API call.
         *
         * @param {string} message Text to be placed in pre element.
         */
        function appendPre(message) {
          var pre = document.getElementById('content');
          var textContent = document.createTextNode(message + '\n');
          pre.appendChild(textContent);
        }
  
        /**
         * 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() {
          gapi.client.calendar.events.list({
            'calendarId': 'primary',
            'timeMin': (new Date()).toISOString(),
            'showDeleted': false,
            'singleEvents': true,
            'maxResults': 10,
            'orderBy': 'startTime'
          }).then(function(response) {
            var events = response.result.items;
            appendPre('Upcoming events:');
  
            if (events.length &gt; 0) {
              for (i = 0; i &lt; events.length; i++) {
                var event = events[i];
                var when = event.start.dateTime;
                if (!when) {
                  when = event.start.date;
                }
                appendPre(event.summary + ' (' + when + ')')
              }
            } else {
              appendPre('No upcoming events found.');
            }
          });
        }
  
      &lt;/script&gt;
  
      &lt;script async defer src="https://apis.google.com/js/api.js"
        onload="this.onload=function(){};handleClientLoad()"&gt;
        onreadystatechange ="if (this.readyState === 'complete') this.onload()"
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>