简体   繁体   中英

Auto login to website using Google Apps Script

I want to auto-login on the website https://www.shiftboard.com/log-in/ using Google apps script. Here is my google apps script code

function login() {
  var payload =
  {
     "auth_user" : "",
     "auth_password" : "",
  };
  var options =
  {
     "method" : "post",
     "payload" : payload,
     "followRedirects" : false
  };
  var login = UrlFetchApp.fetch("https://www.shiftboard.com/log-in/" , options);
  var sessionDetails = login.getAllHeaders()
  Logger.log(sessionDetails)
}

In logger, Output is like that

在此处输入图片说明

I did not get any cookies

If you look at login form's form tag in the HTML code of https://www.shiftboard.com/log-in/ , you can see that it actually submits to /servola/auth.cgi .

The form tag:

<form class="login-form" method="post" action="/servola/auth.cgi">

This means that fetch("https://www.shiftboard.com/log-in/" , options) should be changed to fetch("https://www.shiftboard.com/servola/auth.cgi" , options) .

I assume you are aware, but there is a documented API for Shiftboard .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM