使用oauth令牌更新Google Fusiontable? [英] update Google fusiontable using oauth token?

查看:113
本文介绍了使用oauth令牌更新Google Fusiontable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有了令牌,并且可以访问其作用域直到可融合的令牌. http://www.udayan2k12.com/token.html

I already have the token and can access my token whose scopes are till fusiontable. http://www.udayan2k12.com/token.html

<script type="text/javascript">
   (function() {
     var GOOGLE_AUTH_URL = "https://accounts.google.com/o/oauth2/auth";
     var GOOGLE_CLIENT_ID = "365219651081-7onk7h52kas6cs5m17t1api72ur5tcrh.apps.googleusercontent.com";
     var PLUS_ME_SCOPE = "https://www.googleapis.com/auth/fusiontables";

     var button = document.createElement("button");
     button.innerText = "Authenticate with Google";
     button.onclick = function() {
       var req = {
         "authUrl" : GOOGLE_AUTH_URL,
         "clientId" : GOOGLE_CLIENT_ID,
         "scopes" : [ PLUS_ME_SCOPE ],
       };
       oauth2.login(req, function(token) {
         alert("Got an OAuth token:\n" + token + "\n"
             + "Token expires in " + oauth2.expiresIn(req) + " ms\n");
             document.getElementById('token').innerHTML = token;
       }, function(error) {
         alert("Error:\n" + error);
       });
     };
     document.body.appendChild(button);

     var clearTokens = document.createElement("button");
     clearTokens.innerText = "Clear all tokens";
     clearTokens.onclick = oauth2.clearAllTokens;
     document.body.appendChild(clearTokens);
   })();
  </script>

但是问题是我无法使用该令牌更新融合表. 我想通过使用JavaScript专门对其进行更新.

But the problem is that i am unable to use that token to update the fusion table. I want to update it specifically by using JavaScript.

有人可以向我提供代码以使用此令牌通过融合表sql更新融合表

can some one provide me the code to use this token to update fusiontable using the fusion table sql

推荐答案

我知道你们中的大多数人都在遭受Google身份验证以及插入和更新融合表的痛苦. 我提供了完整的代码,说明如何使用gauth库以简单的方式插入

I know most of you are suffering for google auth and inserting and updating fusion table. I am providing the entire code how to use the gauth lib to insert in a simple manner

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Authorization Request</title>
<script src="https://apis.google.com/js/client.js"></script>
    <script type="text/javascript">
      function auth() {
        var config = {
          'client_id': '365219651081-7onk7h52kas6cs5m17t1api72ur5tcrh.apps.googleusercontent.com',
          'scope': 'https://www.googleapis.com/auth/fusiontables'
        };
        gapi.auth.authorize(config, function() {
          console.log('login complete');
          console.log(gapi.auth.getToken());
        });
      }
      function insert_row(){
            alert("insert called");
            gapi.client.setApiKey('AIzaSyA0FVy-lEr_MPGk1p_lHSrxGZDcxy6wH4o');

            var query = "INSERT INTO 1T_qE-o-EtX24VZASFDn6p3mMoPcWQ_GyErJpPIc(Name, Age) VALUES ('Trial', 100)";

            gapi.client.load('fusiontables', 'v1', function(){
                gapi.client.fusiontables.query.sql({sql:query}).execute(function(response){console.log(response);});
            });

        }
    </script>
</head>

<body>
<button onclick="auth();">Authorize</button>
<p>&nbsp;</p>
<button onclick="insert_row();">Insert Data</button>
</body>
</html>

这篇关于使用oauth令牌更新Google Fusiontable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆