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
#8
(22.10.2020, 08:23)admin Wrote: Header is missing:
Code:
["Content-Type"] = "application/x-www-form-urlencoded"

 yes, now i get the authorization code (authCode).

Next is exchaging the authorization code for an access token, see my code try below.
Doc: https://interop.ondilo.com/docs/api/cust...n-exchange
Code:
-- exchange the authorization code for an access token
  if authCode then
    url = apiHost..endpointToken..'?code='..authCode..'&grant_type=authorization_code&client_id=customer_api&redirect_uri='..uri
    method = "POST"
    local response_body = {}
    local res, code, response_headers, status = socket.http.request
    {
      url = url,
      method = method,
      headers =
      {
        ["Content-Type"] = "application/x-www-form-urlencoded"
      },
      source = ltn12.source.string(''),
      sink = ltn12.sink.table(response_body)
    }
    log(res, code, response_headers, status)
  end

but as usually i received an error  Big Grin
Code:
* arg: 1
  * number: 1
* arg: 2
  * number: 400
* arg: 3
  * table:
   ["server"]
    * string: Apache/2.4.29 (Ubuntu)
   ["content-type"]
    * string: application/json
   ["connection"]
    * string: close
   ["access-control-allow-methods"]
    * string: GET, POST, PUT, PATCH, DELETE, OPTIONS
   ["access-control-allow-headers"]
    * string: X-Requested-With, Content-Type, Accept, Origin, Authorization
   ["cache-control"]
    * string: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0
   ["pragma"]
    * string: no-cache
   ["date"]
    * string: Thu, 22 Oct 2020 11:14:32 GMT
   ["content-length"]
    * string: 97
   ["access-control-allow-origin"]
    * string: *
   ["access-control-allow-credentials"]
    * string: true
* arg: 4
  * string: HTTP/1.1 400 Bad Request
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 admin - 22.10.2020, 08:23
RE: Ondilo spa/pool monitor - by gjniewenhuijse - 22.10.2020, 11:20
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: