Skip to content

Commit

Permalink
fix: fetching jwt token
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekkleszcz committed Mar 2, 2024
1 parent 0b89f94 commit 40f8d34
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/const/url.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const API_URL = 'https://api.ocp.electrolux.one/one-account-user/api/v1';
export const API_URL = 'https://api.ocp.electrolux.one';
9 changes: 6 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import fs from 'fs';
import path from 'path';
import { Region } from './definitions/region';
import { IdentityProvidersResponse } from './definitions/identityProviders';
import { API_URL } from './const/url';

/*
HomebridgePlatform
Expand Down Expand Up @@ -153,7 +154,7 @@ export class ElectroluxDevicesPlatform implements DynamicPlatformPlugin {
});

const tokenResponse = await axiosAuth.post<TokenResponse>(
'/token',
'/one-account-authorization/api/v1/token',
{
grantType:
'urn:ietf:params:oauth:grant-type:token-exchange',
Expand All @@ -162,7 +163,7 @@ export class ElectroluxDevicesPlatform implements DynamicPlatformPlugin {
scope: ''
},
{
baseURL: `${this.regionalBaseUrl}/one-account-authorization/api/v1`,
baseURL: API_URL,
headers: {
'Origin-Country-Code': 'PL'
}
Expand All @@ -176,7 +177,7 @@ export class ElectroluxDevicesPlatform implements DynamicPlatformPlugin {
this.log.info('JWT token successfully fetched!');
}

const regionResponse = await axiosApi.get<IdentityProvidersResponse>('/identity-providers', {
const regionResponse = await axiosApi.get<IdentityProvidersResponse>('/one-account-user/api/v1/identity-providers', {
headers: {
Authorization: `Bearer ${this.accessToken}`
}
Expand All @@ -200,6 +201,8 @@ export class ElectroluxDevicesPlatform implements DynamicPlatformPlugin {
}
});
} catch (err) {
console.log(err);

Check warning on line 204 in src/platform.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

Unexpected console statement

Check warning on line 204 in src/platform.ts

View workflow job for this annotation

GitHub Actions / lint (20.x)

Unexpected console statement

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const message = (err as any).response?.data?.message ?? (err as Error).message;

Expand Down

0 comments on commit 40f8d34

Please sign in to comment.