Logging on to website

I’m unsure if this is the correct forum, but maybe someone has a solution regarding header options.

If I attempt to execute the following google apps script I receive
a blank dialog having a title of “demo”, and a response code of 302.
This dialog is attached. Then if I click on the “follow redirects” message I receive a error dialog, and this is also attached.

I don’t have experience with authentication so I’m kind of in the dark. Does someone dialog-1 dialog-2 know if there is a problem with the options, or if it’s something else?

Thanks,


function logon0() {
//
// Logon to dashboard
//
var url = “https://www.######.com/login”;
var user = “######”;
var password = “######”;
var options = {muteHttpExceptions: true,
followRedirects: false};
options.headers = {“Authorization”: "Basic " + Utilities.base64Encode(user + “:” + password) };
var response = UrlFetchApp.fetch(url, options);
var cookie = response.getAllHeaders()[‘Set-Cookie’];
var opt2 = {muteHttpExceptions: true,
“headers”:
{Cookie: cookie},
followRedirects: false
};
var response2 = UrlFetchApp.fetch(“https://www.######.com/app/v4/dashboard”,opt2);
var ui = HtmlService.createHtmlOutput(response2.getContentText());
SpreadsheetApp.getUi().showModelessDialog(ui,“demo”);
Logger.log(response2.getContentText());
}