homebridge-melcloud-control 4.0.0-beta.336 → 4.0.0-beta.338
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 +1 -1
- package/src/melcloudhometoken.js +12 -7
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.
|
|
4
|
+
"version": "4.0.0-beta.338",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/melcloudhometoken.js
CHANGED
|
@@ -86,21 +86,26 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
86
86
|
|
|
87
87
|
async getTokens(code, codeVerifier) {
|
|
88
88
|
try {
|
|
89
|
-
const
|
|
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
|
-
})
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const tokenResponse = await axios(TOKEN_ENDPOINT, tokenData.toString(), {
|
|
98
|
+
method: 'POST',
|
|
96
99
|
headers: {
|
|
97
100
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
98
|
-
'
|
|
99
|
-
|
|
101
|
+
'Content-Length': tokenData.toString().length,
|
|
102
|
+
'Authorization': 'Basic aG9tZW1vYmlsZTo=',
|
|
103
|
+
},
|
|
100
104
|
});
|
|
105
|
+
const tokens = JSON.parse(tokenResponse);
|
|
101
106
|
|
|
102
|
-
this.emit('warn', `Token ${
|
|
103
|
-
return
|
|
107
|
+
this.emit('warn', `Token ${tokens}`);
|
|
108
|
+
return tokens;
|
|
104
109
|
} catch (error) {
|
|
105
110
|
console.error('Failed to obtain OAuth tokens:', error);
|
|
106
111
|
throw error;
|