我在更新融合表的电子表格中运行的代码有问题。我运行以下代码(出于隐私考虑,省略了融合表 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;
}
我继续收到错误:https ://www.google.com/accounts/ClientLogin 的请求失败,返回代码 403。服务器响应:Error=BadAuthentication(第 97 行)
我了解编码,但对服务器和程序相互交互的方式知之甚少,我的 Formula Team 网站的代码已传递给我,这一切都让我有点不知所措,我不知道该怎么做。
任何帮助是极大的赞赏!