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.

http request => coockies error
#1
Hello,

I'm trying to connect to the dashboard of my heatpump but I'm getting a "coockies error". 

Code:
require('socket.http')
require('ltn12')
require('json')

email = "?"
password = "?"


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

body = encodepost({
  account = email,
  pwd = password,
  code = "",
})

cookies = '...'
cookies = cookies:gsub('Expires=%w+, ', 'Expires=')
cookies = cookies:split(', ')

for i, cookie in ipairs(cookies) do
  cookies[i] = cookie:split(';')[1]
end

cookies = table.concat(cookies, '; ')

headers = {
  ["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0",
  ["Origin"] = "https://www.mydewarmte.com/",
  ["Referer"] = "https://www.mydewarmte.com",
  ["host"] = "www.mydewarmte.com",
  ["Coockie"] = coockies;
}

response = {}

res, code, hdrs, stat = socket.http.request({
  url = "https://mydewarmte.com/",
  method = "POST";
  headers = headers,
  Cookie = cookies,
  source = ltn12.source.string(body),
  sink = ltn12.sink.table(response),
})

log(res, code, hdrs, stat, response)


From the log:
Code:
* arg: 1
  * number: 1
* arg: 2
  * number: 403
* arg: 3
  * table:
   ["server"]
    * string: nginx/1.18.0 (Ubuntu)
   ["content-type"]
    * string: text/html; charset=utf-8
   ["connection"]
    * string: close
   ["content-length"]
    * string: 2891
   ["cross-origin-opener-policy"]
    * string: same-origin
   ["referrer-policy"]
    * string: same-origin
   ["x-frame-options"]
    * string: DENY
   ["date"]
    * string: Wed, 06 Nov 2024 18:34:45 GMT
   ["x-content-type-options"]
    * string: nosniff
* arg: 4
  * string: HTTP/1.1 403 Forbidden
* arg: 5
  * table:
   [1]
    * string:  <!--assets-->
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/static/web_app/images/Logo.png">

    <!-- Bootstrap CSS -->
    <link href="/static/web_app/css/styles.css" rel="stylesheet" >

   

<style>
    @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;400;500;800;900&display=swap');

    /*iot lost css start*/
.iot-lost-container {
    width: 90vw;;
    padding: 20px;
    background-color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    text-align: center;
    margin: 10px 36px;
}

.iot-lost-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-lost-iot-image {
    width: 116px;
    height: auto;
}

.iot-lost-title {
    margin-top: 10px;
    font-size: 24px;
    color: #000000;
}

.a-u-lost {
    margin-top: 30px;
    font-size: 20px;
    color: #555;
}

.links-iot-lost-title {
    margin: 10px 0;
    font-size: 16px;
    color: #777;
}

.links-iot-lost {
    color: #7AB4A8;
    text-decoration: none;
    margin: 5px;
}

.links-iot-lost:hover {
    text-decoration: underline;
}

lu {
    list-style-type: none;
    padding: 0;
}

li {
    margin-top: 10px;
}

.support-email {
    color: #DEAE8A;
}
</style>



    <title> COOKIES ERROR </title>
  </head>
  <body>
    <div class="container">
      <!-- to render block content-->
     
    <div class="iot-lost-container">
        <div class="iot-lost-logo">
            <a href="https://www.dewarmte.nl" target="_blank">
                <img class="logo-lost-iot-image" src="/static/web_app/images/Logo_black2.png">
            </a>
            <h1 class="iot-lost-title">DeWarmte</h1>
        </div>
        <!-- your_csrf_error_template.html -->
        <h1>CSRF Verification Failed</h1>
        <h2 class="a-u-lost">Are you lost?</h2>
        <p class="links-iot-lost-title">Here are some helpful links:</p>
        <lu>
            <li>
                <a class ="links-iot-lost" href="/status">Status</a>
                <a class ="links-iot-lost" href="/dashboard/">Dashboard</a>
                <a class ="links-iot-lost" href="/">Go back Home</a>
            </li>
        </lu>
        <p>We're sorry, but we couldn't verify your request. Please try again.</p>
        <p>Error details: Origin checking failed - https://www.mydewarmte.com/ does not match any trusted origins.</p>
        <p>Please contact the support team to solve the issue!</p>
        <p>You can reach us on <a class="support-email" href="mailto:support@dewarmte.nl">support@dewarmte.nl</a> or <a class="support-email" href="mailto:webapp_userfeedback@dewarmte.nl">webapp_userfeedback@dewarmte.nl</a></p>
    </div>

     
     
                 
    </div>
  </body>
</html>


In case it helps, a homeassistant integration can be found here => https://gathering.tweakers.net/forum/lis...4#79837384
Reply
#2
Please send your access credentials via PM.
Reply


Forum Jump: