Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/server/strava/strava.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ export type WebhookEvent = z.infer<typeof WebhookEvent>;

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;

Expand All @@ -194,7 +196,7 @@ export class StravaApi {

public async deauthorize(accessToken: string): Promise<void> {
try {
await axios.post<void>(`${this.baseUrl}oauth/revoke`, null, {
await axios.post<void>(`${this.oauthUrl}revoke`, null, {
params: { token: accessToken },
auth: { username: this.#clientId, password: this.#clientSecret },
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/server/strava/strava.api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) }),
Expand Down
Loading