diff --git a/src/server/strava/strava.api.ts b/src/server/strava/strava.api.ts index 48fad9ea..e4b0a26e 100644 --- a/src/server/strava/strava.api.ts +++ b/src/server/strava/strava.api.ts @@ -168,6 +168,8 @@ export type WebhookEvent = z.infer; export class StravaApi { private readonly baseUrl = 'https://www.strava.com/api/v3/'; + // oauth/revoke (unlike oauth/token) is not mirrored under /api/v3/ - it 404s there. + private readonly oauthUrl = 'https://www.strava.com/oauth/'; readonly #clientId: string; readonly #clientSecret: string; @@ -194,7 +196,7 @@ export class StravaApi { public async deauthorize(accessToken: string): Promise { try { - await axios.post(`${this.baseUrl}oauth/revoke`, null, { + await axios.post(`${this.oauthUrl}revoke`, null, { params: { token: accessToken }, auth: { username: this.#clientId, password: this.#clientSecret }, }); diff --git a/test/unit/server/strava/strava.api.spec.ts b/test/unit/server/strava/strava.api.spec.ts index a2c6d653..c8d81fef 100644 --- a/test/unit/server/strava/strava.api.spec.ts +++ b/test/unit/server/strava/strava.api.spec.ts @@ -55,7 +55,7 @@ describe('Strava API', () => { await api.deauthorize('token'); expect(axios.post).toHaveBeenCalledTimes(1); - expect(axios.post).toHaveBeenCalledWith('https://www.strava.com/api/v3/oauth/revoke', null, { + expect(axios.post).toHaveBeenCalledWith('https://www.strava.com/oauth/revoke', null, { params: { token: 'token' }, // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment auth: expect.objectContaining({ username: expect.any(String), password: expect.any(String) }),