2019-06-23 03:35:23 -07:00
|
|
|
import {
|
2022-06-26 15:55:51 -07:00
|
|
|
IAuthenticateGeneric,
|
2022-04-19 03:36:01 -07:00
|
|
|
ICredentialTestRequest,
|
2019-06-23 03:35:23 -07:00
|
|
|
ICredentialType,
|
2021-06-12 09:39:55 -07:00
|
|
|
INodeProperties,
|
2019-06-23 03:35:23 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class SlackApi implements ICredentialType {
|
|
|
|
name = 'slackApi';
|
|
|
|
displayName = 'Slack API';
|
2020-08-17 05:42:09 -07:00
|
|
|
documentationUrl = 'slack';
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2019-06-23 03:35:23 -07:00
|
|
|
{
|
|
|
|
displayName: 'Access Token',
|
|
|
|
name: 'accessToken',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2022-11-01 09:41:45 -07:00
|
|
|
typeOptions: { password: true },
|
2019-06-23 03:35:23 -07:00
|
|
|
default: '',
|
2021-09-11 01:15:36 -07:00
|
|
|
required: true,
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
];
|
2022-06-26 15:55:51 -07:00
|
|
|
|
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
2022-04-19 03:36:01 -07:00
|
|
|
properties: {
|
2022-06-26 15:55:51 -07:00
|
|
|
headers: {
|
|
|
|
Authorization: '=Bearer {{$credentials.accessToken}}',
|
|
|
|
},
|
2022-04-19 03:36:01 -07:00
|
|
|
},
|
|
|
|
};
|
2022-06-26 15:55:51 -07:00
|
|
|
|
2022-04-19 03:36:01 -07:00
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: 'https://slack.com',
|
|
|
|
url: '/api/users.profile.get',
|
|
|
|
},
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
type: 'responseSuccessBody',
|
|
|
|
properties: {
|
2022-04-22 03:45:11 -07:00
|
|
|
key: 'error',
|
|
|
|
value: 'invalid_auth',
|
2022-04-19 03:36:01 -07:00
|
|
|
message: 'Invalid access token',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|