Repository: slackapi/node-slack-sdk (TypeScript)

Issue:
web-api: oauth.v2.exchange is missing token parameter
The arguments for `oauth.v2.exchange` are defined by `OAuthV2ExchangeArguments`.

```ts
export interface OAuthV2ExchangeArguments extends Pick<OAuthCredentials, 'client_id' | 'client_secret'> {
}
```
It seems like the `token` parameter is missing here.

#### Packages:

Select all that apply:

- [x] `@slack/web-api`
- [ ] `@slack/rtm-api`
- [ ] `@slack/webhooks`
- [ ] `@slack/oauth`
- [ ] `@slack/socket-mode`
- [ ] `@slack/types`
- [ ] I don't know

### Reproducible in:

#### Slack SDK version: "@slack/web-api": "^7.0.2",



Discussion:
Hmm I suppose [the v6.x line of this module papered over this by extending from `WebApiCallOptions` which allowed for any property to be passed in](https://github.com/slackapi/node-slack-sdk/blob/%40slack/web-api%406.12.0/packages/web-api/src/methods.ts#L2192-L2195) - but also didn't explicitly require a token.

The [API reference docs for this method are also not very extensive](https://api.slack.com/methods/oauth.v2.exchange) 😞 

Looking into it!
The fix is now live in 7.0.4 of the library: https://github.com/slackapi/node-slack-sdk/releases/tag/%40slack%2Fweb-api%407.0.4 and on npm. Thanks for reporting!
BTW the docs also got updated 😄 https://api.slack.com/methods/oauth.v2.exchange



Patch:
diff --git a/packages/web-api/src/types/request/oauth.ts b/packages/web-api/src/types/request/oauth.ts
index d5af94784..5acaed690 100644
--- a/packages/web-api/src/types/request/oauth.ts
+++ b/packages/web-api/src/types/request/oauth.ts
@@ -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;
+}


Test patch:
diff --git a/packages/web-api/test/types/methods/oauth.test-d.ts b/packages/web-api/test/types/methods/oauth.test-d.ts
index 1e1ec23b8..3056677dd 100644
--- a/packages/web-api/test/types/methods/oauth.test-d.ts
+++ b/packages/web-api/test/types/methods/oauth.test-d.ts
@@ -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,
 }]);