자격 증명 파일
n8n v2.29자격 증명 파일은 노드의 인증 방식을 정의합니다. 자격 증명 파일에서는 모든 n8n UI 요소를 사용할 수 있습니다. 자격 증명 파일은 다음과 같은 기본 구조를 따릅니다. 문자열. 문자열. 문자열. 문자열. 객체. n8n이 자격 증명을 테스트하는 데 사용할 수 있는 URL과 인증 타입을 포함하는 request 객체를 제공합니다.
자격 증명 파일은 노드의 인증 방식을 정의합니다. 이 파일의 설정은 n8n이 Credentials 모달에서 표시하는 내용에 영향을 미치며, 연결하려는 서비스의 인증 요구 사항을 반영해야 합니다.
자격 증명 파일에서는 모든 n8n UI 요소를 사용할 수 있습니다. n8n은 자격 증명을 사용하여 저장된 데이터를 암호화 키로 암호화합니다.
자격 증명 파일 구조#
자격 증명 파일은 다음과 같은 기본 구조를 따릅니다.
- Import 문
- 자격 증명을 위한 클래스 생성
- 클래스 내에서 노드의 인증을 제어하는 속성 정의
개요 구조#
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class ExampleNode implements ICredentialType {
name = 'exampleNodeApi';
displayName = 'Example Node API';
documentationUrl = '';
properties: INodeProperties[] = [
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
default: '',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
// Can be body, header, qs or auth
qs: {
// Use the value from `apiKey` above
'api_key': '={{$credentials.apiKey}}'
}
},
};
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials?.domain}}',
url: '/bearer',
},
};
}
매개변수#
name#
문자열. 객체의 내부 이름입니다. 노드의 다른 위치에서 이를 참조할 때 사용됩니다.
displayName#
문자열. n8n이 GUI에서 사용하는 이름입니다.
documentationUrl#
문자열. 자격 증명 문서의 URL입니다.
properties#
각 객체는 다음을 포함합니다.
displayName: n8n이 GUI에서 사용하는 이름입니다.name: 객체의 내부 이름입니다. 노드의 다른 위치에서 이를 참조할 때 사용됩니다.type:string과 같이 예상되는 데이터 타입입니다.default: n8n이 자격 증명을 테스트할 때 사용해야 하는 URL입니다.
authenticate#
authenticate: 객체. n8n에게 API 요청의 일부로 인증 데이터를 주입하는 방법을 알려주는 객체를 포함합니다.
type#
문자열. 헤더, 본문(body) 또는 쿼리 문자열에 데이터를 전송하는 인증 방식을 사용하는 경우 이 값을 'generic'으로 설정합니다.
properties#
객체. 인증 방식을 정의합니다. 옵션은 다음과 같습니다.
body: 객체. 요청 본문(body)에 인증 데이터를 전송합니다. 중첩된 객체를 포함할 수 있습니다.
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
body: {
username: '={{$credentials.username}}',
password: '={{$credentials.password}}',
},
},
};
header: 객체. 요청 헤더에 인증 데이터를 전송합니다.
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
header: {
Authorization: '=Bearer {{$credentials.authToken}}',
},
},
};
qs: 객체. "query string(쿼리 문자열)"의 약자입니다. 요청 쿼리 문자열에 인증 데이터를 전송합니다.
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
qs: {
token: '={{$credentials.token}}',
},
},
};
auth: 객체. Basic Auth에 사용됩니다. 키 이름으로username과password가 필요합니다.
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
auth: {
username: '={{$credentials.username}}',
password: '={{$credentials.password}}',
},
},
};
test#
n8n이 자격 증명을 테스트하는 데 사용할 수 있는 URL과 인증 타입을 포함하는 request 객체를 제공합니다.
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials?.domain}}',
url: '/bearer',
},
};