I am trying to create this google script code that'll help me acquiring some information, however, when I'm fetching the web pages I want, it fails because of the Authentication.
The website itself doesn't have any APIs, and no OAuth.
basically what I need to do is call this function:
function testlogin()
{
var var1 = 'Email' ;
var var2 = 'Password' ;
if( validationLoginForm(var1,var2 ) ) {
document.loginForm.action="/login.do";
document.loginForm.method="post";
document.loginForm.submit();
return true;
} else {
return false;
}
}
// Validation For Login Page. ( login.jsp)
function validationLoginForm(var1, var2){
// For User name
validatorForMandatoryField(document.loginForm.userName ,var1);
// For Password
validatorForMandatoryField(document.loginForm.password ,var2);
// Get the any alert message.
if ( getAlertMsg()!= '' ) {
alert( getAlertMsg() );
alertMsg = '';
if(field != ''){
focusField = field;
focusField.focus();
}
field = '';
return false;
}
return true;
}
This function is present over the website I'm accessing, myaiesec.net and I want to give it an Email and password to "act" as if I logged in over my Google script shown below.
function myFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A2");
var id = range.getValue();
//login here
var response = UrlFetchApp.fetch("http://www.myaiesec.net/exchange/viewtn.do?operation=executeAction&tnId="+id);
sheet.getRange("C2").setValue(response);
}