I tried the code below to login to a website, except it produce the error I've listed.
<pre><code>
function fetchUrlWithCookie() {
var url = "
https://www.someurl/login";
var user = "name";
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}
};
var response2 = UrlFetchApp.fetch("
https://www.someurl/app/v4/dashboard",opt2);
var ui = HtmlService.createHtmlOutput(response2.getContentText());
SpreadsheetApp.getUi().showModelessDialog(ui,"demo");
Logger.log(response2.getContentText());
}
</code></pre>
-----------------------------------------------------------------------------------------------------------------------------------------------------
/*
In order to use this page, your browser needs to accept cookies from
www.someurl.com Please enable cookies in your browser preferences and reload this page.
*/