0

Fusion テーブルを更新するスプレッドシートで実行しているコードに問題があります。次のコードを実行します (プライバシーのためにフュージョン テーブル ID は省略されています)。

 function updateFusion() {

    var tableIDFusion = '##############################'
    var email = UserProperties.getProperty('email'); 
    var password = UserProperties.getProperty('password');     
      if (email === null || password === null) {
        email = Browser.inputBox('Enter email');
        password = Browser.inputBox('Enter password'); 
        UserProperties.setProperty('email',email); 'email'
        UserProperties.setProperty('password', password); 
      }
      var authToken = getGAauthenticationToken(email,password); 
      deleteData(authToken, tableIDFusion); 
      updateData(authToken, tableIDFusion); 
      SpreadsheetApp.getActiveSpreadsheet().toast(Logger.getLog(), "Fusion Tables Update", 10) 
    }

    //Google Authentication API this is taken directly from the google fusion api website
    function getGAauthenticationToken(email, password) {
      password = encodeURIComponent(password);
      var response = UrlFetchApp.fetch("https://www.google.com/accounts/ClientLogin", {
          method: "post",
          payload: "accountType=GOOGLE&Email=" + email + "&Passwd=" + password + "&service=fusiontables&Source=testing"});
      var responseStr = response.getContentText();
      responseStr = responseStr.slice(responseStr.search("Auth=") + 5, responseStr.length);
      responseStr = responseStr.replace(/\n/g, "");
      return responseStr;
    }

引き続きエラーが発生します: Request failed for https://www.google.com/accounts/ClientLogin returned code 403. Server response: Error=BadAuthentication (line 97)

私はコーディングを理解していますが、サーバーやプログラムが相互に作用する方法やフォーミュラ チームの Web サイトのコードが渡されたことについてはあまり理解していません。

どんな助けでも大歓迎です!

4

1 に答える 1

0

私はこのバージョンの同様のスクリプトを使用しています。John McGrathは、Google Fusion Tables グループを通じて、Google スプレッドシートと Google Fusion Table の間の手動の「同期」を作成するためにすべてをまとめました。

似ているとは思いますが、見落としている部分があるのではないでしょうか?

必要に応じてスクリプトを少し変更し、元のバージョンが SQL API エンドポイントを使用していたため、API キー新しい Fusion Tables API エンドポイントの使用を追加しましたが、これは段階的に廃止されています。

使用するには、Fusion Table の暗号化されたテーブル ID をスクリプトの先頭に追加するだけです...

// Add the encrypted table ID of the fusion table here
var tableIDFusion = '17xnxY......';

そしてあなたのAPIキーを追加してください...

// key needed for fusion tables api
var fusionTablesAPIKey = '17xnxY......';
于 2013-01-15T05:55:06.810 に答える