2019-06-23 03:35:23 -07:00
|
|
|
import {
|
2022-06-26 15:55:51 -07:00
|
|
|
IAuthenticateGeneric,
|
2022-05-31 00:46:20 -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 GithubApi implements ICredentialType {
|
|
|
|
name = 'githubApi';
|
2022-05-24 02:36:19 -07:00
|
|
|
displayName = 'GitHub API';
|
2020-08-17 05:42:09 -07:00
|
|
|
documentationUrl = 'github';
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2020-04-02 08:05:28 -07:00
|
|
|
{
|
2020-04-03 02:48:34 -07:00
|
|
|
displayName: 'Github Server',
|
|
|
|
name: 'server',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2020-04-02 08:05:28 -07:00
|
|
|
default: 'https://api.github.com',
|
2021-08-21 05:25:42 -07:00
|
|
|
description: 'The server to connect to. Only has to be set if Github Enterprise is used.',
|
2020-04-02 08:05:28 -07:00
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
{
|
|
|
|
displayName: 'User',
|
|
|
|
name: 'user',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2019-06-23 03:35:23 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Access Token',
|
|
|
|
name: 'accessToken',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2019-06-23 03:35:23 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
];
|
2022-06-26 15:55:51 -07:00
|
|
|
|
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
|
|
type: 'generic',
|
2022-05-31 00:46:20 -07:00
|
|
|
properties: {
|
2022-06-26 15:55:51 -07:00
|
|
|
headers: {
|
|
|
|
Authorization: '=token {{$credentials?.accessToken}}',
|
|
|
|
},
|
2022-05-31 00:46:20 -07:00
|
|
|
},
|
|
|
|
};
|
2022-06-26 15:55:51 -07:00
|
|
|
|
2022-05-31 00:46:20 -07:00
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: '={{$credentials?.server}}',
|
|
|
|
url: '/user',
|
|
|
|
method: 'GET',
|
|
|
|
},
|
|
|
|
};
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|