2023-01-27 03:22:44 -08:00
import type { ICredentialType , INodeProperties } from 'n8n-workflow' ;
2020-03-05 15:25:18 -08:00
//https://api.slack.com/authentication/oauth-v2
2020-03-08 15:22:33 -07:00
const userScopes = [
2023-01-05 05:02:16 -08:00
'channels:read' ,
2022-05-24 00:12:10 -07:00
'channels:write' ,
2020-03-08 15:22:33 -07:00
'chat:write' ,
'files:read' ,
'files:write' ,
2020-12-13 01:47:52 -08:00
'groups:read' ,
'im:read' ,
'mpim:read' ,
'reactions:read' ,
'reactions:write' ,
2020-03-08 15:22:33 -07:00
'stars:read' ,
'stars:write' ,
2021-11-03 17:55:04 -07:00
'usergroups:write' ,
'usergroups:read' ,
2020-10-01 22:31:41 -07:00
'users.profile:read' ,
2020-10-22 06:46:03 -07:00
'users.profile:write' ,
2022-09-29 02:26:51 -07:00
'users:read' ,
2020-03-15 07:51:49 -07:00
] ;
2020-03-08 15:22:33 -07:00
2020-03-05 15:25:18 -08:00
export class SlackOAuth2Api implements ICredentialType {
name = 'slackOAuth2Api' ;
2022-12-02 12:54:28 -08:00
2022-07-24 08:36:17 -07:00
extends = [ 'oAuth2Api' ] ;
2022-12-02 12:54:28 -08:00
2020-03-05 15:25:18 -08:00
displayName = 'Slack OAuth2 API' ;
2022-12-02 12:54:28 -08:00
2020-08-17 05:42:09 -07:00
documentationUrl = 'slack' ;
2022-12-02 12:54:28 -08:00
2021-06-12 09:39:55 -07:00
properties : INodeProperties [ ] = [
2022-06-13 22:27:19 -07:00
{
displayName : 'Grant Type' ,
name : 'grantType' ,
type : 'hidden' ,
default : 'authorizationCode' ,
} ,
2020-03-05 15:25:18 -08:00
{
displayName : 'Authorization URL' ,
name : 'authUrl' ,
2021-06-12 09:39:55 -07:00
type : 'hidden' ,
2020-03-05 15:25:18 -08:00
default : 'https://slack.com/oauth/v2/authorize' ,
} ,
{
displayName : 'Access Token URL' ,
name : 'accessTokenUrl' ,
2021-06-12 09:39:55 -07:00
type : 'hidden' ,
2020-03-05 15:25:18 -08:00
default : 'https://slack.com/api/oauth.v2.access' ,
} ,
//https://api.slack.com/scopes
{
displayName : 'Scope' ,
name : 'scope' ,
2021-06-12 09:39:55 -07:00
type : 'hidden' ,
2020-03-05 15:25:18 -08:00
default : 'chat:write' ,
} ,
{
displayName : 'Auth URI Query Parameters' ,
name : 'authQueryParameters' ,
2021-06-12 09:39:55 -07:00
type : 'hidden' ,
2020-03-08 15:22:33 -07:00
default : ` user_scope= ${ userScopes . join ( ' ' ) } ` ,
2020-03-05 15:25:18 -08:00
} ,
{
displayName : 'Authentication' ,
name : 'authentication' ,
2021-06-12 09:39:55 -07:00
type : 'hidden' ,
2020-03-05 15:25:18 -08:00
default : 'body' ,
} ,
2023-02-03 08:04:37 -08:00
{
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 : '' ,
} ,
2020-03-05 15:25:18 -08:00
] ;
}