1

我在本地为融合表设置我需要从融合表中插入和获取结果我从站点复制代码但它总是从我那里生成一个错误
当我尝试获取结果并插入结果时它会从我那里生成一个错误我无法获取结果

[
 {
  "error": {
   "code": 403,
   "message": "Access Not Configured",
   "data": [
    {
     "domain": "usageLimits",
     "reason": "accessNotConfigured",
     "message": "Access Not Configured"
    }
   ]
  },
  "id": "gapiRpc"
 }
]

Please help me for fixed id 

Here is my code i am locally setup for this

var clientId = '877036777031-oiac9p32ujf3hoqamrm99lrkavkb72mg.apps.googleusercontent.com';
var apiKey = 'AIzaSyDaeSEkUfh8tSbXyfGb_l4e3uf2lVOFbrI';
var scopes = 'https://www.googleapis.com/auth/plus.me';
var tableId = '1SyGe4OV4OeP8OkUScxuYBEmeC4IGSo0me6Tg0RE';
var clientSecret = '1z_OFh5HcxQp_mS2rUkroi-8';
        function handleClientLoad() {
            // Step 2: Reference the API key
            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 && !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() {
            gapi.client.load('plus', 'v1', function() {
                var request = gapi.client.plus.people.get({
                    'userId': 'me'
                });
                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);
                });
            });
        }
        // 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) {
            getGAauthenticationToken('bharatjain.aloha@gmail.com', 'aloha@123');
            gapi.auth.authorize({
                client_id: clientId,
                client_secret: clientSecret,
                scope: scopes,
                immediate: immediate
            }, handleAuthResult);
        }

        // Run a request to create a new Fusion Table.
        function createTable() {
            var tableResource = [];
            tableResource.push('{');
            tableResource.push('"Text": "Number",');
            tableResource.push('"columns": [');
            tableResource.push('{ "name": "Name", "type": "STRING" },');
            tableResource.push('{ "name": "Age", "type": "NUMBER" }');
            tableResource.push('],')
            tableResource.push('"isExportable": true');
            tableResource.push('}');
            runClientRequest({
                path: '/fusiontables/v1/tables',
                body: tableResource.join(''),
                method: 'POST'
            }, function(resp) {
                var output = JSON.stringify(resp);
                document.getElementById('create-table-output').innerHTML = output;
                tableId = resp['tableId'];
                document.getElementById('table-id-1').innerHTML = tableId;
                document.getElementById('table-id-2').innerHTML = tableId;
                document.getElementById('insert-data').disabled = false;
                document.getElementById('select-data').disabled = false;
                document.getElementById('create-table').disabled = true;
            });
        }

        // Run a request to INSERT data.
        function insertData() {
            var name = document.getElementById('name').value;
            var age = document.getElementById('age').value;
            var insert = [];
            insert.push('INSERT INTO ');
            insert.push(tableId);
            insert.push(' (Text, Number) VALUES (');
            insert.push("'" + name + "', ");
            insert.push(age);
            insert.push(')');
            query(insert.join(''));
        }

        // Run a request to SELECT data.
        function selectData() {
            query('SELECT * FROM ' + tableId);
        }

        // Send an SQL query to Fusion Tables.
        function query(query) {
            var lowerCaseQuery = query.toLowerCase();
            var path = '/fusiontables/v1/query';
            var callback = function(element) {
                return function(resp) {
                    var output = JSON.stringify(resp);
                    document.getElementById(element).innerHTML = output;
                };
            }
            if (lowerCaseQuery.indexOf('select') != 0 &&
                lowerCaseQuery.indexOf('show') != 0 &&
                lowerCaseQuery.indexOf('describe') != 0) {
                var body = 'sql=' + encodeURIComponent(query);
                runClientRequest({
                    path: path,
                    body: body,
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded',
                        'Content-Length': body.length
                    },
                    method: 'POST',
                    userName: 'bharatjain.jaw@gmail.com',
                    password: 'mayank19jain'
                }, callback('insert-data-output'));

            } else {
                runClientRequest({
                    path: path,
                    params: { 'sql': query }
                }, callback('select-data-output'));
            }
        }

        // Execute the client request.
        function runClientRequest(request, callback) {
            var restRequest = gapi.client.request(request);
            restRequest.execute(callback);
        }
    </script>
    <script src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>
</head>
<body>
<h1>
    Fusion Tables JavaScript Example
</h1>
<h2>
    (1) Authorize using OAuth 2.0
</h2>
<p>
    Click Authorize to start the OAuth 2.0 authorization flow. If you have
    already authorized, the button will be disabled.
</p>
<input type="button" id="authorize-button" value="Authorize"><br>

<h2>
    (2) Create Table
</h2>
<p>
    Click "Create Table" to create an exportable Fusion Table called "People"
    with columns "Name" with type "STRING" and "Age" with type "NUMBER".
      <pre>
{
  "name": "People",
  "columns": [
    {
      "name": "Name",
      "type": "STRING"
    }, {
      "name": "Age",
      "type": "NUMBER"
    }
  ],
  "isExportable": true
}</pre>
</p>
<input type="button" id="create-table" value="Create Table"
       disabled="disabled">
<p id="create-table-output"><i>table response goes here...</i></p><br>

<h2>
    (3) Insert data
</h2>
<p>
    Insert data into the newly created table.
</p>
<pre>INSERT INTO <span id="table-id-1">[table_id]</span> (Name, Age) VALUES ([name], [age])</pre>
<label>Name:</label>
<input type="text" id="name"><br>
<label>Age:</label>
<input type="age" id="age"><br>
<input type="button" id="insert-data" value="Insert data">
<p id="insert-data-output"><i>insert response goes here...</i></p><br>

<h2>
    (4) Select all the rows from the table
</h2>
<p>
    Select the data that has been inserted into the newly created table.
</p>
<pre>SELECT * FROM <span id="table-id-2">[table_id]</span></pre>
<input type="button" id="select-data" value="Select data">
<p id="select-data-output"><i>select response goes here...</i></p>
</body>
</html>
4

0 回答 0