I am trying to fetch information from a site with basic authentication (username and password), I followed documentation and some forums here, but I can't get it to work.
Whenever I run the function, it returns the HTML from the login website, as if the authentication isn't working.
function getRequest() {
var url = "URL";
var username = "USER";
var password = "PASSWRD";
var headers = {
"Authorization" : "Basic " + Utilities.base64Encode(username + ":" + password)
};
var params = {
"method":"GET",
"headers": headers
};
const response = UrlFetchApp.fetch(url, params);
Logger.log(response.getContentText());
}
I need it to return the contents from the website already logged in.