08.08.2022, 06:04
Use this:
The request_url in RequestFromEbeco is wrong, it should be "https://ebecoconnect.com/api/services/app/Devices/GetUserDevices" (without any additional parameters).
Code:
function GetToken()
local response_body = {}
local request_body = json.encode({
userNameOrEmailAddress = userNameOrEmailAddress,
password = password,
})
local body, code, hdrs, stat = ssl.https.request{
url = 'https://ebecoconnect.com/api/TokenAuth/Authenticate',
method = 'POST',
headers = {
['Content-Type'] = 'application/json',
['Content-Length'] = #request_body,
['Abp.TenantId'] = 1,
},
source = ltn12.source.string(request_body),
sink = ltn12.sink.table(response_body),
}
if code == 200 then
ret = table.concat(response_body)
ret = json.pdecode(ret)
log(ret)
return ret.access_token -- could be some other field, try to log ret to be sure
else
log('request failed', body, code, hdrs, stat)
end
end
The request_url in RequestFromEbeco is wrong, it should be "https://ebecoconnect.com/api/services/app/Devices/GetUserDevices" (without any additional parameters).