Hilfe durchsuchen

Vorsicht vor Support-Betrug: Wir fordern Sie niemals auf, eine Telefonnummer anzurufen, eine SMS an eine Telefonnummer zu senden oder persönliche Daten preiszugeben. Bitte melden Sie verdächtige Aktivitäten über die Funktion „Missbrauch melden“.

Learn More

I'm using Google Apps Script1 to login to a website, except the intended page doesn't appear.

  • 2 Antworten
  • 1 hat dieses Problem
  • 2 Aufrufe
  • Letzte Antwort von cor-el

more options

I'm not certain if this is the appropriate forum. However, maybe someone understands header options and cookies.

If I execute the following google apps script I receive a blank dialog with a title of "demo", and a response code of 302. This dialog is attached.

If I next click on the "follow redirects" message I receive a error dialog, and this is also attached.

I'm kind of in the dark regarding authentication. Does someone 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());

}


I'm not certain if this is the appropriate forum. However, maybe someone understands header options and cookies. If I execute the following google apps script I receive a blank dialog with a title of "demo", and a response code of 302. This dialog is attached. If I next click on the "follow redirects" message I receive a error dialog, and this is also attached. I'm kind of in the dark regarding authentication. Does someone 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()); } -------------------------------------------------------------------------------------------------------
Angefügte Screenshots

Alle Antworten (2)

more options

Do you have some reason to suspect that Lumosity supports basic access authentication? If it did, you wouldn't need any cookies. It looks like cookies are obtained via POST request to "www.lumosity.com/authentication" rather than requesting "www.lumosity.com/login"

Do you particularly want to do this with Lumosity, or is it just an example. It would be easier to start with a few that have a documented login process for learning purposes.

more options

This can happen if you open a website in a (i)frame and the website prohibits this via CSP.