05.07.2021, 13:50
I've tried the following
however the way I'm passing the AuthCookie token doesn't seem correct as this is the error I get back from the Powerwall
How should the cookie / token value be set in the request header?
Kind Regards
James
Code:
socket = require('socket')
ssl = require('ssl')
client = socket.tcp()
client:settimeout(1)
ip = 'POWERWALLGATEWAYIP'
token = GetUserParam('Wired', 'TeslaPowerwallLocalAccessToken')
params = {mode='client', protocol='tlsv1_2',verify='none',}
res, err = client:connect(ip, 443)
ctx = ssl.newcontext(params)
client = ssl.wrap(client, ctx)
client:settimeout(1)
res, err = client:dohandshake()
res, err = client:send(
'GET /api/system_status/soe HTTP/1.1' .. '\r\n' ..
'Host: ' .. ip .. '\r\n' ..
'Set-Cookie: ' .. token .. '\r\n' ..
'User-Agent: curl/7.64.1' .. '\r\n' ..
'Accept: */*' .. '\r\n' ..
'Connection: close' .. '\r\n\r\n'
)
res, err, partial = client:receive('*a')
log('receive', res, err, partial)
client:close()
however the way I'm passing the AuthCookie token doesn't seem correct as this is the error I get back from the Powerwall
Code:
* arg: 1
* string: receive
* arg: 2
* string: HTTP/1.1 403 Forbidden
Content-Type: application/json
X-Content-Type-Options: nosniff
Date: Mon, 05 Jul 2021 13:44:08 GMT
Content-Length: 102
Connection: close
{"code":403,"error":"Unable to GET to resource","message":"User does not have adequate access rights"}
* arg: 3
* nil
* arg: 4
* nil
How should the cookie / token value be set in the request header?
Kind Regards
James