凭据文件#
¥Credentials file
凭证文件定义了节点的授权方法。此文件中的设置会影响 n8n 在“凭据”模态框中显示的内容,并且必须反映你连接服务的身份验证要求。
¥The credentials file defines the authorization methods for the node. The settings in this file affect what n8n displays in the Credentials modal, and must reflect the authentication requirements of the service you're connecting to.
在凭据文件中,你可以使用所有 n8n UI 元素。n8n 使用加密密钥对通过凭据存储的数据进行加密。
¥In the credentials file, you can use all the n8n UI elements. n8n encrypts the data that's stored using credentials using an encryption key.
凭证文件结构#
¥Structure of the credentials file
凭证文件遵循以下基本结构:
¥The credentials file follows this basic structure:
- 导入语句
¥Import statements 2. 创建凭据类
¥Create a class for the credentials 3. 在类中,定义控制节点身份验证的属性。
¥Within the class, define the properties that control authentication for the node.
结构概要#
¥Outline structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
参数#
¥Parameters
name#
字符串。对象的内部名称。用于从节点中的其他位置引用它。
¥String. The internal name of the object. Used to reference it from other places in the node.
displayName#
字符串。n8n 在 GUI 中使用的名称。
¥String. The name n8n uses in the GUI.
documentationUrl#
字符串。你的凭据文档的 URL。
¥String. URL to your credentials documentation.
properties#
每个对象包含:
¥Each object contains:
displayName:n8n 在 GUI 中使用的名称。
¥displayName: the name n8n uses in the GUI.
name:对象的内部名称。用于从节点中的其他位置引用它。
¥name: the internal name of the object. Used to reference it from other places in the node.
type:预期的数据类型,例如string。
¥type: the data type expected, such as string.
default:n8n 用于测试凭据的 URL。
¥default: the URL that n8n should use to test credentials.
authenticate#
authenticate:对象。包含告知 n8n 如何将身份验证数据作为 API 请求的一部分注入的对象。
¥authenticate: Object. Contains objects that tell n8n how to inject the authentication data as part of the API request.
type#
字符串。如果你使用的身份验证方法在标头、正文或查询字符串中发送数据,请将其设置为 'generic'。
¥String. If you're using an authentication method that sends data in the header, body, or query string, set this to 'generic'.
properties#
对象。定义身份验证方法。选项包括:
¥Object. Defines the authentication methods. Options are:
body:对象。在请求正文中发送身份验证数据。可以包含嵌套对象。
¥body: Object. Sends authentication data in the request body. Can contain nested objects.
1 2 3 4 5 6 7 8 9 | |
header:对象。在请求头中发送身份验证数据。
¥header: Object. Send authentication data in the request header.
1 2 3 4 5 6 7 8 | |
qs:对象。代表 "查询字符串。"。在请求查询字符串中发送身份验证数据。
¥qs: Object. Stands for "query string." Send authentication data in the request query string.
1 2 3 4 5 6 7 8 | |
auth:对象。用于基本身份验证。需要将username和password设置为键名。
¥auth: Object. Used for Basic Auth. Requires username and password as the key names.
1 2 3 4 5 6 7 8 9 | |
test#
请提供一个包含 URL 和身份验证类型的 request 对象,n8n 可以使用该对象来测试凭据。
¥Provide a request object containing a URL and authentication type that n8n can use to test the credential.
1 2 3 4 5 6 | |