Closed Alex-Jud closed 2 years ago
Will get interesting because I do not have such a devices ... can you please send a full debug log?
I'm not a fluent Js user, can you explain me what for log can I send you?
Noidea how you use the library but basically it is like https://github.com/Apollon77/daikin-controller-cloud/blob/main/example/example.js#L26 ... then you get logging. and set https://github.com/Apollon77/daikin-controller-cloud/blob/main/example/example.js#L27 to "debug"
For testing, i'm using your example.js file with no modifiaction. I launch it thru VisualStudioCode with a javascript debug terminal.
Here is what is debug output:
PS C:\Users\XXXXX\source\repos\daikin-controller-cloud> node .\example\example.js
Debugger attached.
Use Token with the following claims: {"at_hash":"yXIEFw-1sLnbTy-KfO8GJQ","custom:country":"FR","sub":"2deb78bc-345e-48e6-a3e2-a32f3f95dd45","cognito:groups":["eu-west-1_SLI9qJpc7_CDC"],"email_verified":false,"iss":"https://cognito-idp.eu-west-1.amazonaws.com/eu-west-1_SLI9qJpc7","cognito:username":"CDC_2a9282a06dx1240c784e0b9a7ba08211","aud":"7rk39602f0ds8lk0xh076vvijn","identities":[{"userId":"2a9282a06d1240cx784e0b9a7ba08211","providerName":"CDC","providerType":"SAML","issuer":"https://fidm.gigya.com/saml/v2.0/3_xRB3jaQ62bVjqXU1omaEsPDxVYC0Twi1zfq1zHPu_5HFT0zWkDvZJS97Yw1loJnT","primary":"true","dateCreated":"1648275923168"}],"token_use":"id","auth_time":1648456444,"name":"XXXXXXXXXX","exp":1650438111,"iat":1650434511,"email":"XXXXX@XXXXX.com"}
Waiting for the debugger to disconnect...
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
HTTPError: Response code 400 (Bad Request)
at Request.<anonymous> (C:\Users\XXXXX\source\repos\daikin-controller-cloud\node_modules\got\dist\source\as-promise\index.js:117:42)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1651137106951,
socket: 1651137106952,
lookup: 1651137106983,
connect: 1651137107026,
secureConnect: 1651137107134,
upload: 1651137107135,
response: 1651137107208,
end: 1651137107209,
error: undefined,
abort: undefined,
phases: {
wait: 1,
dns: 31,
tcp: 43,
tls: 108,
request: 1,
firstByte: 73,
download: 1,
total: 258
}
}
}
Node.js v17.8.0
PS C:\Users\XXXXX\source\repos\daikin-controller-cloud>
And in debug mode
<-- GET https://api.prod.unicloud.edc.dknadmin.be/v1/gateway-devices
<-- HEADERS {
'user-agent': 'Daikin/1.6.1.4681 CFNetwork/1209 Darwin/20.2.0',
authorization: 'Bearer eyJraWQiOiJ4cGtRMUhsOEppQkFvbWtpekk3d2MwQzh2ekZONEM1aTRya0hoRnBZSzJzPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiIyZGViNzhiYy0zNDVlLTQ4ZTYtYTNlMi1hMzJmM2Y5NWRkNDUiLCJjb2duaXRvOmdyb3VwcyI6WyJldS13ZXN0LTFfU0xJOXFKcGM3X0NEQyJdLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6Im9wZW5pZCIsImF1dGhfdGltZSI6MTY0ODQ1NjQ0NCwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLmV1LXdlc3QtMS5hbWF6b25hd3MuY29tXC9ldS13ZXN0LTFfU0xJOXFKcGM3IiwiZXhwIjoxNjUwNDM4MTExLCJpYXQiOjE2NTA0MzQ1MTEsInZxxxIsImp0aSI6ImI1NDJlZDIxLThmMzctNGZmZC1hZGVkLTdiM2QzNjYwMmYwYSIsImNsaWVudF9pZCI6IjdyazM5NjAyZjBkczhsazBoMDc2dnZpam5iIiwidXNlcm5hbWUiOiJDRENfMmE5MjgyYTA2ZDEyNDBjNzg0ZTBiOWE3YmEwODIxMTUifQ.OYEU0hU-Hw2FoAf3pUqTpq563N2EKd36B_tkM5HVpKJFLPln7e_5Zs4mnZirxDc18KQFmZlkOonRYwqRRqec0dLtTOoVRf4fQDkDIYvE5QfvaWFKIuNmbgk5Q8JgQMwlN5QbxhIJNWtDzvpWttcMsjb6v_klO1V08_v24RPQnFg9Zwj7GgwGG7REznW4inMdXo6jkCoq-58dSDtgOPiLs_3Nya6xcKupYUwe11FCNaVTV6DIjPEJnAho-yJYw3cKNvDdJiQ-Ul1JJD2Ih5bNhVto8-G6RQB8NYy3g74zjUkSq4uMRAPsmuka9c10mYaL6NuJ7DvhbRXuy7suwp8CdA',
'x-api-key': 'xw6gvOtBHq5b1pyceadRp6rujSNSZdjx2AqT03iC',
'accept-encoding': 'gzip, deflate, br'
}
--> 401 FROM GET https://api.prod.unicloud.edc.dknadmin.be/v1/gateway-devices
--> HEADERS {
'content-type': 'application/json',
'content-length': '128',
connection: 'close',
date: 'Thu, 28 Apr 2022 09:19:38 GMT',
'x-amzn-requestid': '2fdce76b-ae02-4c3x-8543-95d3fdc753b0',
'x-amzn-errortype': 'UnauthorizedException',
'x-amz-apigw-id': 'RSNWkGDaDoEFesw=',
'x-cache': 'Error from cloudfront',
via: '1.1 5c0a9fbe4f8b2e7835a09c41c52efb12.cloudfront.net (CloudFront)',
'x-amz-cf-pop': 'CDG52-P1',
'x-amz-cf-id': 'j9CcGfIe2kNf9WeNZkHyMkUyjyzGBCBxxx8MWyRhY8TXX1z-z62jAg=='
}
--> BODY {"code": "UNAUTHORIZED", "message":"The given token is invalid. Check the value of the Authorization HTTP request header."}
<-- POST https://cognito-idp.eu-west-1.amazonaws.com/
<-- HEADERS {
'user-agent': 'Daikin/1.6.1.4681 CFNetwork/1220.1 Darwin/20.3.0',
'content-type': 'application/x-amz-json-1.1',
'x-amz-target': 'AWSCognitoIdentityProviderService.InitiateAuth',
'x-amz-user-agent': 'aws-amplify/0.1.x react-native',
accept: 'application/json',
'content-length': '1787',
'accept-encoding': 'gzip, deflate, br'
}
--> 400 FROM POST https://cognito-idp.eu-west-1.amazonaws.com/
--> HEADERS {
date: 'Thu, 28 Apr 2022 09:19:41 GMT',
'content-type': 'application/x-amz-json-1.1',
'content-length': '73',
connection: 'close',
'x-amzn-requestid': '6c3036dd-efb7-444b-x418-dbf2f8ca78dc',
'x-amzn-errortype': 'NotAuthorizedException:',
'x-amzn-errormessage': 'Refresh Token has expired'
}
--> BODY {
__type: 'NotAuthorizedException',
message: 'Refresh Token has expired'
}
Waiting for the debugger to disconnect...
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
HTTPError: Response code 400 (Bad Request)
at Request.<anonymous> (C:\Users\XXXXX\source\repos\daikin-controller-cloud\node_modules\got\dist\source\as-promise\index.js:117:42)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ERR_NON_2XX_3XX_RESPONSE',
timings: {
start: 1651137580053,
socket: 1651137580054,
lookup: 1651137580086,
connect: 1651137580128,
secureConnect: 1651137580234,
upload: 1651137580235,
response: 1651137580305,
end: 1651137580307,
error: undefined,
abort: undefined,
phases: {
wait: 1,
dns: 32,
tcp: 42,
tls: 106,
request: 1,
firstByte: 70,
download: 2,
total: 254
}
}
}
And when you try to get a new token?
No problem with token generation. And when I test example again with the new token it worked fine.... The update is not in cause... It's seems to be just a token validity expiration...
My apologies
After further exploration, I found that tokensaver.js saved my updated token in my cron job run folder, so my used token is never updated.
Hy, I'm using your library during the last month to manage my "Daikin Altherma 3 H HT W" I've got a cron job to keep track of my energy consumption. But since yesterday 11:00 I've got no more new data. I check today:
i think Daikin has changed something in API... I hope it's a small change!