From d5b3551e67c0d40f6807e93f5e06837d2b7ab065 Mon Sep 17 00:00:00 2001 From: Stefan Nienhuis Date: Thu, 3 Mar 2022 16:58:58 +0100 Subject: [PATCH] Fix authenitcation (for real for real) --- src/bold.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bold.ts b/src/bold.ts index acf6639..3055c6d 100644 --- a/src/bold.ts +++ b/src/bold.ts @@ -24,7 +24,7 @@ export class BoldAPI { private log: Logger ) {} - private async request(method: Method, endpoint: string): Promise> { + private async request(method: Method, endpoint: string, body: unknown | undefined = undefined): Promise> { try { let response = await axios.request({ method: method, @@ -32,7 +32,8 @@ export class BoldAPI { headers: { 'X-Auth-Token': this.authToken, 'Content-Type': 'application/json' - } + }, + data: body }); if ((response.data.errorCode != null && response.data.errorCode != 'OK') && (response.data.errorMessage != null && response.data.errorMessage != 'OK')) { @@ -86,7 +87,7 @@ export class BoldAPI { let devices = response.data as Device[]; let supportedDevices = devices.filter((device) => device.id != null && device.name && device.gateway != null); - console.debug(`Total device count: ${devices.length}, Supported device count: ${supportedDevices.length}`); + this.log.debug(`Total device count: ${devices.length}, Supported device count: ${supportedDevices.length}`); return supportedDevices; } else { @@ -113,7 +114,11 @@ export class BoldAPI { async refreshToken(): Promise { this.log.debug('Refreshing auth token'); - let response = await this.request('PUT', `/v1/authentications/${this.authToken}`); + let response = await this.request('PUT', `/v1/authentications/${this.authToken}`, { + clientType: 'IOS', + clientId: 4952073786011980410, + appId: 'sesam.technology.bold' + }); if (!response.success) { this.log.error(`Error ${response.error.code ? `(${response.error.code}) ` : ''}while refreshing token: ${response.error.message}`);