Skip to content

Commit 9bc2d73

Browse files
committed
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.
1 parent f51ba99 commit 9bc2d73

5 files changed

Lines changed: 5 additions & 8 deletions

File tree

src/authenticator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class RefreshTokenAuthenticator implements Authenticator {
102102
}
103103

104104
const axiosConfig: AxiosRequestConfig = {
105-
url: clientConfig.urlProvider?.authURL,
105+
url: `${clientConfig.urlProvider?.baseURL}/oauth/token`,
106106
method: 'POST',
107107
headers,
108108
data: `grant_type=refresh_token&client_id=${refreshData.clientId}&refresh_token=${refreshData.refreshToken}`,

src/endpoint-client.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ export type HttpClientMethod =
2121

2222
export interface SmartThingsURLProvider {
2323
baseURL: string
24-
authURL?: string
2524
keyApiURL?: string
2625
}
2726

2827
export const globalSmartThingsURLProvider: Required<SmartThingsURLProvider> = {
2928
baseURL: 'https://api.smartthings.com',
30-
authURL: 'https://auth-global.api.smartthings.com/oauth/token',
3129
keyApiURL: 'https://key.smartthings.com',
3230
}
3331

src/st-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class SmartThingsOAuthClient {
103103

104104
constructor(private clientId: string, private clientSecret: string,
105105
private redirectUri: string, urlProvider?: SmartThingsURLProvider) {
106-
this.authURL = urlProvider?.authURL || globalSmartThingsURLProvider.authURL
106+
this.authURL = `${urlProvider?.baseURL || globalSmartThingsURLProvider.baseURL}/oauth/token`
107107
}
108108

109109
// eslint-disable-next-line @typescript-eslint/no-explicit-any

test/unit/authenticator.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('authenticators', () => {
6666

6767
expect(axios.request).toHaveBeenCalledTimes(1)
6868
expect(axios.request).toHaveBeenCalledWith({
69-
'url': 'https://auth-global.api.smartthings.com/oauth/token',
69+
'url': 'https://api.smartthings.com/oauth/token',
7070
'method': 'POST',
7171
'headers': {
7272
'Content-Type': 'application/x-www-form-urlencoded',
@@ -128,7 +128,7 @@ describe('authenticators', () => {
128128

129129
expect(axios.request).toHaveBeenCalledTimes(1)
130130
expect(axios.request).toHaveBeenCalledWith({
131-
'url': 'https://auth-global.api.smartthings.com/oauth/token',
131+
'url': 'https://api.smartthings.com/oauth/token',
132132
'method': 'POST',
133133
'headers': {
134134
'Content-Type': 'application/x-www-form-urlencoded',
@@ -146,7 +146,7 @@ describe('authenticators', () => {
146146

147147
expect(axios.request).toHaveBeenCalledTimes(1)
148148
expect(axios.request).toHaveBeenCalledWith({
149-
'url': 'https://auth-global.api.smartthings.com/oauth/token',
149+
'url': 'https://api.smartthings.com/oauth/token',
150150
'method': 'POST',
151151
'headers': {
152152
'Content-Type': 'application/x-www-form-urlencoded',

test/unit/signature.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ describe('ST Padlock', () => {
4444
const resolver = new HttpKeyResolver({
4545
urlProvider: {
4646
baseURL: 'https://api.smartthings.com',
47-
authURL: 'https://auth-global.api.smartthings.com/oauth/token',
4847
keyApiURL: 'https://keys.smartthingsdev.com',
4948
},
5049
})

0 commit comments

Comments
 (0)