This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Ondilo spa/pool monitor
#6
(22.10.2020, 07:14)admin Wrote: For auth you need to use standard POST, not JSON:

For this request Accept/Content-Type headers are not needed. Add redirect = false to the request table to catch the redirect URL instead of following it.
 
mmm same result with changed code

Code:
function getAuth()
  function encodepost(t)
    local res = {}
    local esc = require('socket.url').escape
    for k, v in pairs(t) do
      res[ #res + 1 ] = esc(k) .. '=' .. esc(v)
    end
    return table.concat(res, '&')
  end
 
  url = apiHost..endpointAuth..'?client_id=customer_api&response_type=code&redirect_uri='..uri..'&scope=api&state='..state
  method = "POST"
  local response_body = {} 
  local payload = encodepost({
    login = usr,
    password = pwd,
    locale = "nl",
    proceed = "Authorize",
  })
  local res, code, response_headers, status = socket.http.request
  {
    url = url,
    method = method,
    redirect = false,
    headers =
    {
      ["Content-Length"] = #payload
    },
    source = ltn12.source.string(payload),
    sink = ltn12.sink.table(response_body)
  }
  if res and code == 200 then
    log(response_body)
    log(res, code, response_headers, status)
  else
    log(res, code, response_headers, status)
  end
end
Reply


Messages In This Thread
Ondilo spa/pool monitor - by gjniewenhuijse - 20.10.2020, 14:46
RE: Ondilo spa/pool monitor - by admin - 22.10.2020, 06:30
RE: Ondilo spa/pool monitor - by admin - 22.10.2020, 07:14
RE: Ondilo spa/pool monitor - by gjniewenhuijse - 22.10.2020, 08:16
RE: Ondilo spa/pool monitor - by admin - 22.10.2020, 08:23
RE: Ondilo spa/pool monitor - by admin - 22.10.2020, 11:24
RE: Ondilo spa/pool monitor - by admin - 23.10.2020, 06:47
RE: Ondilo spa/pool monitor - by MikeBrignate - 21.05.2021, 19:08
RE: Ondilo spa/pool monitor - by admin - 24.05.2021, 09:38
RE: Ondilo spa/pool monitor - by MikeBrignate - 25.05.2021, 07:12
RE: Ondilo spa/pool monitor - by admin - 25.05.2021, 08:19

Forum Jump: