Closed tgu-git closed 1 year ago
Honestly .. maybe try to use valid email and password first? I could very good assume that the > and < is making such an issue.
Of corse I put my valid credentials in the CLI, but didn't share them here at git. Thus I put the placeholders only here. Could the reason for the excepetion my password as it starts with a '^'?
Behavior is the same if I use my valid mail address and a random password without any special character.
Ok, which version of the library did you install?
Hm ... It seems that got changed a parametrr a... will fix that ... grmppfff
I get the same error. Have you made a fix yet? Thanks for your answer!
not yet, hopefully soon. Time is rare becfause of other prios right now
Ok, no problem!
Okay, since today i have the same Issue,
"HTTPError: Response code 400 (Bad Request)"
without any changes in configuration. Is there any Workarround to get an fuctionality state ? Best Regards Rene
Yes get new tokens
That is what I tried to do, but it failed with the above error.
Hhm ... amybe they changed something in their flow and we need to adjust :-(
node example/tokensaver.js "<mail-addresse>" "<password>"
solve the" Bad Request" Issue.
Thanks for the amazing Daikin Module :-)
Just tryed again, but for me the situation is unchanged.
Still get
code: 'ERR_GOT_REQUEST_ERROR'
@skycrack-77 For you it is working, to retrieve the token?
I still can´t get a token. Related: https://github.com/ksacca/daikincloud-domoticz/issues/1 This git is based on daikin-controller-cloud. Using this node red flow I can´t login with or without saving a token.
Had the same problem "ERR_GOT_REQUEST_ERROR" on refreshAccessToken().
postman got the correct response.
I have replaced the call in refreshAccessToken with standard node https request:
This fixed the problem for me.
//-------------------------------------------------------------------------
//-- node https standard call
//-------------------------------------------------------------------------
async doRequestRefreshAccessToken()
{
return new Promise ((resolve, reject) =>
{
var options = {
'method': 'POST',
'hostname': 'cognito-idp.eu-west-1.amazonaws.com',
'path': '/',
'headers': {
'Content-Type': 'application/x-amz-json-1.1',
'x-amz-target': 'AWSCognitoIdentityProviderService.InitiateAuth',
'x-amz-user-agent': 'aws-amplify/0.1.x react-native',
'User-Agent': 'Daikin/1.6.1.4681 CFNetwork/1220.1 Darwin/20.3.0'
},
'maxRedirects': 20
};
var req = https.request(options, function (res)
{
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
resolve(body.toString());
});
res.on("error", function (error) {
reject(error);
});
});
var oPostData =
{
'ClientId': this.openIdClientId,
'AuthFlow': 'REFRESH_TOKEN_AUTH',
'AuthParameters': {
'REFRESH_TOKEN': this.tokenSet.refresh_token
}
}
req.write(JSON.stringify(oPostData));
req.end();
});
}
//-------------------------------------------------------------------------
/**
* Refresh the tokens
* This method normally is called automatically if a 401 response is received,
* so should not be needed to be called manually
*
* On Error the got response is included as property "response" in Error object
*
* @emits DaikinCloudController#token_update
* @returns {Promise<TokenSet>}
*/
async refreshAccessToken() {
//----------------
//-- replace code
//----------------
let strResponseCall = await this.doRequestRefreshAccessToken();
let response = {};
response.body = JSON.parse(strResponseCall);
//-----------------
//-- replaced code
//-----------------
//const response = await got.post('https://cognito-idp.eu-west-1.amazonaws.com', {
// headers: {
// 'Content-Type': 'application/x-amz-json-1.1',
// 'x-amz-target': 'AWSCognitoIdentityProviderService.InitiateAuth',
// 'x-amz-user-agent': 'aws-amplify/0.1.x react-native',
// 'User-Agent': 'Daikin/1.6.1.4681 CFNetwork/1220.1 Darwin/20.3.0'
// },
// json: {
// 'ClientId': this.openIdClientId,
// 'AuthFlow': 'REFRESH_TOKEN_AUTH',
// 'AuthParameters': {
// 'REFRESH_TOKEN': this.tokenSet.refresh_token
// }
// },
// responseType: 'json',
// hooks: {
// beforeRequest: [
// (options) => {
// if (this.options.logLevel === 'debug') {
// console.log('<-- %s %s', options.method.toUpperCase(), options.url.href);
// console.log('<-- HEADERS %o', options.headers);
// if (options.body) {
// console.log('<-- BODY %s', options.body);
// }
// }
// },
// ],
// afterResponse: [
// (response) => {
// if (this.options.logLevel === 'debug') {
// console.log('--> %i FROM %s %s', response.statusCode, response.request.options.method.toUpperCase(), response.request.options.url.href);
// console.log('--> HEADERS %o', response.headers);
// if (response.body) {
// console.log('--> BODY %s', response.body);
// }
// }
// return response;
// }
// ]
// },
// timeout: {
// response: this.options.communicationTimeout,
// request: this.options.communicationTimeout
// },
// retry: {
// retries: this.options.communicationRetries,
// errorCodes: ['ETIMEDOUT'],
// methods: ['GET', 'POST']
// }
//});
if (response.body && response.body.AuthenticationResult && response.body.AuthenticationResult.AccessToken && response.body.AuthenticationResult.TokenType === 'Bearer') {
this.tokenSet.access_token = response.body.AuthenticationResult.AccessToken;
this.tokenSet.id_token = response.body.AuthenticationResult.IdToken;
this.tokenSet.access_token = response.body.AuthenticationResult.AccessToken;
this.tokenSet.expires_at = ~~(Date.now() / 1000) + response.body.AuthenticationResult.ExpiresIn * 1000;
this.emit('token_update', this.tokenSet);
return this.tokenSet;
}
const err = new Error('Token refresh was not successful! ' + response.statusCode);
err.response = response;
throw err;
}
var https = require('follow-redirects').https;
on file head needed
I'd like to retrieve the token from the Daikins Cloud Service using your tokensaver.js script.
I did a git clone from your git repo.
When I execute the tokensaver.js script while providing my Dakin user credentials (mail address + password) I'll receive the following exeption:
System information: $ node --version v16.18.1
$ cat /etc/debian_version 11.5
I'd like to write my own script until an OpenHAB Daikin binding is provided supporting Daikin Cloud Credentials.