title: Google API in Javascript
body: <p>I am trying to get calendar info from google in javascript. I ve read 'how to' manuals. They didn't help. Even this 'helpful' copypasted code (to authorize) didn't. Would somebody be so kind to teach me how to use google api? Maybe someone has some samples to share</p>
  
  <p>And this beautiful js code : </p>
  
  <pre><code>&lt;html&gt;
  &lt;button id="authorize-button" onclick='handleAuthClick()'&gt;Authorize&lt;/button&gt;
  
  &lt;script type="text/javascript"&gt;
      var clientId = '***';
      var apiKey = '***';
      var scopes = 'https://www.googleapis.com/auth/plus.me';
  
      function handleClientLoad() {
          gapi.client.setApiKey(apiKey);
          window.setTimeout(checkAuth,1);
      }
  
      function checkAuth() {
          gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, handleAuthResult);
      }
  
      function handleAuthResult(authResult) {
          var authorizeButton = document.getElementById('authorize-button');
          if (authResult &amp;&amp; !authResult.error) {
              authorizeButton.style.visibility = 'hidden';
              makeApiCall();
          } else {
              authorizeButton.style.visibility = '';
              authorizeButton.onclick = handleAuthClick;
          }
      }
  
      function handleAuthClick(event) {
          // Step 3: get authorization to use private data
          gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult);
          return false;
      }
  
      // Load the API and make an API call.  Display the results on the screen.
      function makeApiCall() {
          // Step 4: Load the Google+ API
          gapi.client.load('plus', 'v1', function() {
              // Step 5: Assemble the API request
              var request = gapi.client.plus.people.get({
              'userId': 'me'
              });
              // Step 6: Execute the API request
              request.execute(function(resp) {
              var heading = document.createElement('h4');
              var image = document.createElement('img');
              image.src = resp.image.url;
              heading.appendChild(image);
              heading.appendChild(document.createTextNode(resp.displayName));
  
              document.getElementById('content').appendChild(heading);
              });
          });
      }
  &lt;/script&gt;
  </code></pre>
  
  
  
  <p></p>
  
  <p>Error Message (from Console):</p>
  
  <pre><code> 'Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null').'
  </code></pre>
  
  <p>so im stuck on 'gapi.auth.authorize'. nothing works after </p>