I am having an issue with code I am running in a spreadsheet that updates a fusion table. I run the following code (with the fusion table ID omitted for privacy).
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;
}
I continue to get the error: Request failed for https://www.google.com/accounts/ClientLogin returned code 403. Server response: Error=BadAuthentication (line 97)
I understand coding but not much about servers and the way programs interact with each other and the code for my Formula Team's website has been passed to me and this is all a bit over my head and I am not sure what to do.
Any help is greatly appreciated!