Skip to content

Commit 3fe47b9

Browse files
Slack: Retry to auth if some scopes are missing (#17640)
1 parent dcb9960 commit 3fe47b9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

extensions/slack/src/tools/set-status.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getSlackWebClient } from "../shared/client/WebClient";
1+
import { getSlackWebClient, slack } from "../shared/client/WebClient";
22
import { withSlackClient } from "../shared/withSlackClient";
33

44
type Input = {
@@ -20,6 +20,8 @@ type Input = {
2020
duration?: number;
2121
};
2222

23+
let retried = false;
24+
2325
async function setStatus(input: Input) {
2426
const slackWebClient = getSlackWebClient();
2527

@@ -32,6 +34,11 @@ async function setStatus(input: Input) {
3234
});
3335

3436
if (res.error) {
37+
if (res.error?.includes("missing_scope") && !retried) {
38+
retried = true;
39+
await slack.client.removeTokens();
40+
return withSlackClient(setStatus)(input);
41+
}
3542
throw new Error(res.error);
3643
}
3744

0 commit comments

Comments
 (0)