From 85881c7c76aa2dd69a9d15fc9eab521c46e4f79e Mon Sep 17 00:00:00 2001 From: Olivier Sambourg Date: Wed, 11 Jun 2025 11:11:16 +0200 Subject: [PATCH] feat(slack): add customizable connection scopes --- packages/pieces/community/slack/package.json | 2 +- packages/pieces/community/slack/src/index.ts | 70 ++++++++++++-------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/packages/pieces/community/slack/package.json b/packages/pieces/community/slack/package.json index 633cb4ace00..18be639e3d6 100644 --- a/packages/pieces/community/slack/package.json +++ b/packages/pieces/community/slack/package.json @@ -1,4 +1,4 @@ { "name": "@activepieces/piece-slack", - "version": "0.9.1" + "version": "0.10.0" } diff --git a/packages/pieces/community/slack/src/index.ts b/packages/pieces/community/slack/src/index.ts index 610d8512d8e..648cc67c676 100644 --- a/packages/pieces/community/slack/src/index.ts +++ b/packages/pieces/community/slack/src/index.ts @@ -45,37 +45,49 @@ import { inviteUserToChannelAction } from './lib/actions/invite-user-to-channel' export const slackAuth = PieceAuth.OAuth2({ description: '', - authUrl: - 'https://slack.com/oauth/v2/authorize?user_scope=search:read,users.profile:write,reactions:read,im:history,stars:read', + authUrl: 'https://slack.com/oauth/v2/authorize?scope={botScopes}&user_scope={userScopes}', tokenUrl: 'https://slack.com/api/oauth.v2.access', required: true, - scope: [ - 'channels:read', - 'channels:manage', - 'channels:history', - 'chat:write', - 'groups:read', - 'groups:write', - 'groups:history', - 'reactions:read', - 'mpim:read', - 'mpim:write', - 'mpim:history', - 'im:write', - 'im:read', - 'im:history', - 'users:read', - 'files:write', - 'files:read', - 'users:read.email', - 'reactions:write', - 'usergroups:read', - 'chat:write.customize', - 'links:read', - 'links:write', - 'emoji:read', - 'users.profile:read' - ], + props: { + botScopes: Property.ShortText({ + displayName: 'Bot scopes', + description: 'Comma-separated list of scopes for the bot token', + required: true, + defaultValue: + 'channels:read,channels:manage,' + + 'channels:history,' + + 'chat:write,' + + 'groups:read,' + + 'groups:write,' + + 'groups:history,' + + 'reactions:read,' + + 'mpim:read,' + + 'mpim:write,' + + 'mpim:history,' + + 'im:write,' + + 'im:read,' + + 'im:history,' + + 'users:read,' + + 'files:write,' + + 'files:read,' + + 'users:read.email,' + + 'reactions:write,' + + 'usergroups:read,' + + 'chat:write.customize,' + + 'links:read,' + + 'links:write,' + + 'emoji:read,' + + 'users.profile:read', + }), + userScopes: Property.ShortText({ + displayName: 'User scopes', + description: 'Comma-separated list of scopes for the user token', + required: true, + defaultValue: + 'search:read,users.profile:write,reactions:read,im:history,stars:read', + }), + }, + scope: ["{botScopes}"], }); export const slack = createPiece({