JS oauth fusion table v1

by witold

HTML

<!DOCTYPE html>
<!--
  Copyright 2011 Google Inc. All Rights Reserved.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<html>
  <head>
    <title>JavaScript API Example</title>

    <style type="text/css">
      body { font-family: Arial; }
    </style>
    <script type="text/javascript">
      // The clientId and apiKey are available at
      // https://code.google.com/apis/console. For more information, see
      // http://code.google.com/p/google-api-javascript-client/wiki/Authentication.
      var clientId = '668625057927.apps.googleusercontent.com';
      var apiKey = 'AIzaSyBwlgQ1sX-Fk8agu-5nSEOKyq8GTfASYHM';

      var scopes = 'https://www.googleapis.com/auth/fusiontables';
      var tableId;

      // Initialize the client, set onclick listeners.
      function initialize() {
        gapi.client.setApiKey(apiKey);
        document.getElementById('create-table').onclick = createTable;
        document.getElementById('insert-data').onclick = insertData;
        document.getElementById('select-data').onclick = selectData;
        window.setTimeout(function() { auth(true); }, 1);
      }

      // Run OAuth 2.0 authorization.
      function auth(immediate) {
        gapi.auth.authorize({
          client_id: clientId,
          scope: scopes,
          immediate: immediate
        }, handleAuthResult);
      }

      // Handle the results of the OAuth 2.0 flow.
      function handleAuthResult(authResult) {
        var authorizeButton =...