I'm trying to login to a website with my username and password. When click login in the homepage, it will popup a form to enter username only and we need to click next button to enter the password.
The header, payload and url login in my code was get from chrome developer tool.
But my code below will always timeout out when been executed. Any wrong with my code?
I have tried to googling for similar case with mine but can't find any.
function toped() {
var loginURL = 'https://www.*****.com/api/authorize?theme=popup&ld=https%3A%2F%2Fwww.*****.com%2F';
var loginPayload = {
'email': 'email@yahoo.co.id',
'password': 'password'
};
var headers = {
'Connection':'keep-alive',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9',
'accept': 'accept: application/json, text/javascript, */*; q=0.01',
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36',
};
var loginOptions = {
'method':'POST',
'headers': headers,
'payload':loginPayload,
'followRedirects': true,
'muteHttpExceptions': true
};
var loginResponse = UrlFetchApp.fetch(loginURL, loginOptions);
Logger.log(loginResponse.getResponseCode());
Logger.log(loginResponse.getAllHeaders());
}
I expect my code to return a response in the logger, but always timeout.