2022-06-14 16:31:05 +02:00
|
|
|
import {
|
2022-06-29 14:12:28 +02:00
|
|
|
IAuthenticateGeneric,
|
2022-06-14 16:31:05 +02:00
|
|
|
ICredentialTestRequest,
|
|
|
|
|
ICredentialType,
|
|
|
|
|
INodeProperties,
|
2022-06-20 15:22:10 +02:00
|
|
|
} from 'n8n-workflow';
|
2022-06-14 16:31:05 +02:00
|
|
|
|
|
|
|
|
export class HttpBinApi implements ICredentialType {
|
2022-06-20 15:22:10 +02:00
|
|
|
name = 'httpbinApi';
|
|
|
|
|
displayName = 'HttpBin API';
|
2025-05-13 14:26:01 +01:00
|
|
|
documentationUrl = 'https://your-docs-url';
|
2022-06-14 16:31:05 +02:00
|
|
|
properties: INodeProperties[] = [
|
|
|
|
|
{
|
2022-06-20 15:22:10 +02:00
|
|
|
displayName: 'Token',
|
|
|
|
|
name: 'token',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
2024-07-04 19:44:50 +02:00
|
|
|
typeOptions: {
|
|
|
|
|
password: true,
|
|
|
|
|
}
|
2022-06-14 16:31:05 +02:00
|
|
|
},
|
|
|
|
|
{
|
2022-06-20 15:22:10 +02:00
|
|
|
displayName: 'Domain',
|
|
|
|
|
name: 'domain',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: 'https://httpbin.org',
|
2022-06-14 16:31:05 +02:00
|
|
|
},
|
|
|
|
|
];
|
2022-06-16 11:53:57 +02:00
|
|
|
|
2022-06-29 14:12:28 +02:00
|
|
|
// This allows the credential to be used by other parts of n8n
|
|
|
|
|
// stating how this credential is injected as part of the request
|
|
|
|
|
// An example is the Http Request node that can make generic calls
|
|
|
|
|
// reusing this credential
|
2022-11-23 09:37:42 +01:00
|
|
|
authenticate: IAuthenticateGeneric = {
|
2022-06-29 14:12:28 +02:00
|
|
|
type: 'generic',
|
|
|
|
|
properties: {
|
2022-06-29 16:27:55 +02:00
|
|
|
headers: {
|
|
|
|
|
Authorization: '={{"Bearer " + $credentials.token}}',
|
2022-06-29 14:12:28 +02:00
|
|
|
},
|
|
|
|
|
},
|
2022-11-23 09:37:42 +01:00
|
|
|
};
|
2022-06-16 11:53:57 +02:00
|
|
|
|
2022-06-29 14:12:28 +02:00
|
|
|
// The block below tells how this credential can be tested
|
2022-06-14 16:31:05 +02:00
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
|
request: {
|
2022-06-20 15:22:10 +02:00
|
|
|
baseURL: '={{$credentials?.domain}}',
|
|
|
|
|
url: '/bearer',
|
2022-06-14 16:31:05 +02:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|