Namokonov

gas_get_cookie

Sep 12th, 2021
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Получаем cookie, отправляя логин и пароль
  2.  
  3. function getDoggyLogsCookie() {
  4.   let url = 'https://doggylogs.com/login/authenticate'
  5.   let params = {
  6.     method: "POST",
  7.     'contentType': 'application/x-www-form-urlencoded',
  8.     "followRedirects": false,
  9.     'payload': {
  10.       'username': '123', 'password': '456'
  11.     }
  12.   };
  13.  
  14.   let resp = UrlFetchApp.fetch(url, params)
  15.   let headers = resp.getAllHeaders();
  16.   let cookies = headers['Set-Cookie'].split(';')[0];
  17.  
  18.   Logger.log(cookies);
  19.   return cookies;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment