Skip to content

Commit

Permalink
web-api(fix): oauth.v2.exchange method requires a token parameter (#1779
Browse files Browse the repository at this point in the history
)
  • Loading branch information
filmaj authored Apr 19, 2024
1 parent 3ebb6ce commit ae755dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/web-api/src/types/request/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export interface OAuthAccessArguments extends OAuthCredentials {
// https://api.slack.com/methods/oauth.v2.access
export interface OAuthV2AccessArguments extends OAuthCredentials, OAuthGrantRefresh {}
// https://api.slack.com/methods/oauth.v2.exchange
export interface OAuthV2ExchangeArguments extends Pick<OAuthCredentials, 'client_id' | 'client_secret'> {}
export interface OAuthV2ExchangeArguments extends Pick<OAuthCredentials, 'client_id' | 'client_secret'> {
/** @description The legacy xoxb or xoxp token being migrated. */
token: string;
}
20 changes: 18 additions & 2 deletions packages/web-api/test/types/methods/oauth.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,28 @@ expectAssignable<Parameters<typeof web.oauth.v2.access>>([{
expectError(web.oauth.v2.exchange()); // lacking argument
expectError(web.oauth.v2.exchange({})); // empty argument
expectError(web.oauth.v2.exchange({
client_id: 'C1234', // missing client_secret
client_id: 'C1234', // missing client_secret, token
}));
expectError(web.oauth.v2.exchange({
client_secret: '1234.567', // missing `client_id`
client_secret: '1234.567', // missing `client_id`, token
}));
expectError(web.oauth.v2.exchange({
token: 'xoxp-blah', // missing `client_id`, client_secret
}));
expectError(web.oauth.v2.exchange({
client_id: 'C1234',
client_secret: '1234.567', // missing token
}));
expectError(web.oauth.v2.exchange({
client_id: 'C1234',
token: 'xoxb-blah', // missing client_secret
}));
expectError(web.oauth.v2.exchange({
client_secret: '1234.567',
token: 'xoxb-blah', // missing client_id
}));
// -- happy path
expectAssignable<Parameters<typeof web.oauth.v2.exchange>>([{
token: 'xoxb-blah',
...creds,
}]);

0 comments on commit ae755dc

Please sign in to comment.