homebridge-melcloud-control 4.0.0-beta.336 → 4.0.0-beta.337

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.0-beta.336",
4
+ "version": "4.0.0-beta.337",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -86,18 +86,22 @@ class MelCloudHomeToken extends EventEmitter {
86
86
 
87
87
  async getTokens(code, codeVerifier) {
88
88
  try {
89
- const tokenResponse = await this.client.post(TOKEN_ENDPOINT, new URLSearchParams({
89
+ const tokenData = new URLSearchParams({
90
90
  grant_type: 'authorization_code',
91
- client_id: CLIENT_ID,
92
91
  code: code,
93
92
  redirect_uri: REDIRECT_URI,
93
+ client_id: CLIENT_ID,
94
94
  code_verifier: codeVerifier,
95
- }).toString(), {
95
+ });
96
+
97
+ const tokenResponse = await axios(TOKEN_ENDPOINT, {
98
+ method: 'POST',
96
99
  headers: {
97
100
  'Content-Type': 'application/x-www-form-urlencoded',
98
- 'Authorization': 'Basic aG9tZW1vYmlsZTo='
99
- }
100
- });
101
+ 'Content-Length': tokenData.toString().length,
102
+ 'Authorization': 'Basic aG9tZW1vYmlsZTo=',
103
+ },
104
+ }, tokenData.toString());
101
105
 
102
106
  this.emit('warn', `Token ${tokenResponse.data}`);
103
107
  return tokenResponse.data;