From 9bc2d7379c5bd273680a378653871f0eed6ddba5 Mon Sep 17 00:00:00 2001 From: Bob Florian Date: Wed, 27 May 2026 13:08:23 -0400 Subject: [PATCH] fix: use baseURL for OAuth token endpoint rather tnan separate authURL The searate authURL is no longer used in documentation and not guaranteed to be supported in the future. This change only impacts TypeScipt integrations to pre-production SmartThings environments (which require URL overriding). Integrations to the production environment using default URLs are not affected. --- src/authenticator.ts | 2 +- src/endpoint-client.ts | 2 -- src/st-client.ts | 2 +- test/unit/authenticator.test.ts | 6 +++--- test/unit/signature.test.ts | 1 - 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/authenticator.ts b/src/authenticator.ts index 667849ad..cce0248c 100644 --- a/src/authenticator.ts +++ b/src/authenticator.ts @@ -102,7 +102,7 @@ export class RefreshTokenAuthenticator implements Authenticator { } const axiosConfig: AxiosRequestConfig = { - url: clientConfig.urlProvider?.authURL, + url: `${clientConfig.urlProvider?.baseURL}/oauth/token`, method: 'POST', headers, data: `grant_type=refresh_token&client_id=${refreshData.clientId}&refresh_token=${refreshData.refreshToken}`, diff --git a/src/endpoint-client.ts b/src/endpoint-client.ts index c42653c5..f2750ec0 100644 --- a/src/endpoint-client.ts +++ b/src/endpoint-client.ts @@ -21,13 +21,11 @@ export type HttpClientMethod = export interface SmartThingsURLProvider { baseURL: string - authURL?: string keyApiURL?: string } export const globalSmartThingsURLProvider: Required = { baseURL: 'https://api.smartthings.com', - authURL: 'https://auth-global.api.smartthings.com/oauth/token', keyApiURL: 'https://key.smartthings.com', } diff --git a/src/st-client.ts b/src/st-client.ts index 46d9ec55..fada99e0 100644 --- a/src/st-client.ts +++ b/src/st-client.ts @@ -103,7 +103,7 @@ export class SmartThingsOAuthClient { constructor(private clientId: string, private clientSecret: string, private redirectUri: string, urlProvider?: SmartThingsURLProvider) { - this.authURL = urlProvider?.authURL || globalSmartThingsURLProvider.authURL + this.authURL = `${urlProvider?.baseURL || globalSmartThingsURLProvider.baseURL}/oauth/token` } // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/test/unit/authenticator.test.ts b/test/unit/authenticator.test.ts index 9fbc24fd..3c7e5f0e 100644 --- a/test/unit/authenticator.test.ts +++ b/test/unit/authenticator.test.ts @@ -66,7 +66,7 @@ describe('authenticators', () => { expect(axios.request).toHaveBeenCalledTimes(1) expect(axios.request).toHaveBeenCalledWith({ - 'url': 'https://auth-global.api.smartthings.com/oauth/token', + 'url': 'https://api.smartthings.com/oauth/token', 'method': 'POST', 'headers': { 'Content-Type': 'application/x-www-form-urlencoded', @@ -128,7 +128,7 @@ describe('authenticators', () => { expect(axios.request).toHaveBeenCalledTimes(1) expect(axios.request).toHaveBeenCalledWith({ - 'url': 'https://auth-global.api.smartthings.com/oauth/token', + 'url': 'https://api.smartthings.com/oauth/token', 'method': 'POST', 'headers': { 'Content-Type': 'application/x-www-form-urlencoded', @@ -146,7 +146,7 @@ describe('authenticators', () => { expect(axios.request).toHaveBeenCalledTimes(1) expect(axios.request).toHaveBeenCalledWith({ - 'url': 'https://auth-global.api.smartthings.com/oauth/token', + 'url': 'https://api.smartthings.com/oauth/token', 'method': 'POST', 'headers': { 'Content-Type': 'application/x-www-form-urlencoded', diff --git a/test/unit/signature.test.ts b/test/unit/signature.test.ts index 60767f06..e86b22c8 100644 --- a/test/unit/signature.test.ts +++ b/test/unit/signature.test.ts @@ -44,7 +44,6 @@ describe('ST Padlock', () => { const resolver = new HttpKeyResolver({ urlProvider: { baseURL: 'https://api.smartthings.com', - authURL: 'https://auth-global.api.smartthings.com/oauth/token', keyApiURL: 'https://keys.smartthingsdev.com', }, })