n8n/packages/nodes-base/credentials/SlackOAuth2Api.credentials.ts
yehorkardash 64079ad98c
feat(core): Agents as first class entities support (no-changelog) (#28017)
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Michael Drury <michael.drury@n8n.io>
Co-authored-by: Arvin A <51036481+DeveloperTheExplorer@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Arvin Ansari <arvin.ansari@n8n.io>
Co-authored-by: bjorger <50590409+bjorger@users.noreply.github.com>
Co-authored-by: Eugene <eugene@n8n.io>
Co-authored-by: Michael Drury <me@michaeldrury.co.uk>
Co-authored-by: Robin Braumann <robin.braumann@n8n.io>
Co-authored-by: Rob Hough <robhough180@gmail.com>
2026-05-06 15:44:44 +00:00

125 lines
2.8 KiB
TypeScript

import type { ICredentialType, INodeProperties } from 'n8n-workflow';
//https://api.slack.com/authentication/oauth-v2
export const userScopes = [
'channels:read',
'channels:write',
'channels:history',
'chat:write',
'files:read',
'files:write',
'groups:read',
'groups:history',
'im:read',
'im:history',
'mpim:read',
'mpim:history',
'reactions:read',
'reactions:write',
'stars:read',
'stars:write',
'usergroups:write',
'usergroups:read',
'users.profile:read',
'users.profile:write',
'users:read',
'search:read',
];
export class SlackOAuth2Api implements ICredentialType {
name = 'slackOAuth2Api';
extends = ['oAuth2Api'];
displayName = 'Slack OAuth2 API';
documentationUrl = 'slack';
properties: INodeProperties[] = [
{
displayName: 'Signature Secret',
name: 'signatureSecret',
type: 'string',
typeOptions: { password: true },
default: '',
description:
'The signing secret is used to verify the authenticity of requests sent by Slack.',
},
{
displayName: 'Grant Type',
name: 'grantType',
type: 'hidden',
default: 'authorizationCode',
},
{
displayName: 'Authorization URL',
name: 'authUrl',
type: 'hidden',
default: 'https://slack.com/oauth/v2/authorize',
},
{
displayName: 'Access Token URL',
name: 'accessTokenUrl',
type: 'hidden',
default: 'https://slack.com/api/oauth.v2.access',
},
{
displayName: 'Scope',
name: 'scope',
type: 'hidden',
default: '',
},
{
displayName: 'Custom Scopes',
name: 'customScopes',
type: 'boolean',
default: false,
description: 'Define custom scopes',
},
{
displayName:
'The default scopes needed for the node to work are already set. If you change these the node may not function correctly.',
name: 'customScopesNotice',
type: 'notice',
default: '',
displayOptions: {
show: {
customScopes: [true],
},
},
},
{
displayName: 'User Scope',
name: 'userScope',
type: 'string',
displayOptions: {
show: {
customScopes: [true],
},
},
default: userScopes.join(' '),
description: 'Space-separated user-level scopes for your Slack app',
},
//https://api.slack.com/scopes
{
displayName: 'Auth URI Query Parameters',
name: 'authQueryParameters',
type: 'hidden',
default: `={{$self["customScopes"] ? "user_scope=" + $self["userScope"] : "user_scope=${userScopes.join(' ')}"}}`,
},
{
displayName: 'Authentication',
name: 'authentication',
type: 'hidden',
default: 'body',
},
{
displayName:
'If you get an Invalid Scopes error, make sure you add the correct one <a target="_blank" href="https://docs.n8n.io/integrations/builtin/credentials/slack/#using-oauth">here</a> to your Slack integration',
name: 'notice',
type: 'notice',
default: '',
},
];
}