Skip to content

创建和编辑凭据(Create and edit credentials)#

凭据是安全存储的身份验证信息,用于将 n8n 工作流连接到外部服务,例如 API 或数据库。

🌐 Credentials are securely stored authentication information used to connect n8n workflows to external services such as APIs, or databases.

创建凭据(Create a credential)#

  1. 在侧边菜单的左上角选择 通用创建资源图标 创建按钮。选择凭证。
  2. 如果你的 n8n 实例支持 项目,你还需要选择是在你的个人空间中创建凭证,还是在你有访问权限的特定项目中创建。如果你使用的是社区版,则需要在你的个人空间中创建凭证。
  3. 选择要连接的应用或服务。

或:

🌐 Or:

  1. Overview 页面或某个特定项目的右上角使用 通用创建资源图标 创建 按钮。选择 凭证
  2. 如果你是在概览页面进行操作,你将在个人空间内创建凭证。如果你是在某个项目内部操作,你将在该特定项目内创建凭证。
  3. 选择要连接的应用或服务。

你还可以在凭证投放中创建新凭证。在工作流编辑器中编辑节点时,可能会出现此问题。

🌐 You can also create new credential in the credential drop down when editing a node on the workflow editor.

进入凭证模态后,输入你的服务所需的详细信息。有关指导,请参阅你的服务在凭证库中的页面。

🌐 Once in the credential modal, enter the details required by your service. Refer to your service's page in the credentials library for guidance.

保存凭据后,n8n 会对其进行测试以确认其有效。

🌐 When you save a credential, n8n tests it to confirm it works.

凭据命名

n8n 默认将新凭据命名为“节点名称 账户”。你可以通过点击名称来重命名凭据,方式类似于重命名节点。最好给凭据命名时包含应用或服务的名称、类型以及凭据的用途。命名规范可以让你更容易跟踪和识别凭据。

允许的 HTTP 请求域(Allowed HTTP request domains)#

允许的 HTTP 请求域字段出现在许多 n8n 用于基于 Web 的 API 和服务的凭证中。当在HTTP 请求节点中选择凭证时,它控制凭证允许使用的域。 当凭证在其自己的专用节点中使用时,该字段没有效果。

🌐 The Allowed HTTP Request Domains field appears on many n8n credentials for web-based APIs and services. It controls which domains the credential is permitted to be used against when the credential is selected in an HTTP Request node. It has no effect when the credential is used in its own dedicated node.

该字段有三个选项:

🌐 The field has three options:

  • 所有人:该凭证可用于任何网址。
  • 特定字段:限制在特定字段(提供逗号分隔的列表,如 httpbin.org, api.github.com
  • :该凭证在 HTTP 请求 节点中完全被禁止使用。

此字段可以防止凭证被滥用,例如将凭证发送到目标域之外的 URL。

🌐 This field prevents credential misuse, for example sending the credential to URLs outside the intended domain.

凭据中的表达式(Expressions in credentials)#

你可以使用表达式在工作流运行时动态设置凭据:

🌐 You can use expressions to set credentials dynamically as your workflow runs:

  1. 在你的工作流程中,找到包含凭证的数据路径。这取决于你数据中的具体参数名称。当你到达需要它的节点时,确保包含凭证的数据在工作流程中可用。
  2. 创建凭证时,将鼠标悬停在要使用表达式的字段上。
  3. 开启表情
  4. 输入你的表达式。

示例工作流程(Example workflow)#

Workflow preview placeholder.

使用示例(Using the example)#

To load the template into your n8n instance:

  1. Download the workflow JSON file.
  2. Open a new workflow in your n8n instance.
  3. Copy in the JSON, or select Workflow menu Workflow menu icon > Import from file....

The example workflows use Sticky Notes to guide you:

  • Yellow: notes and information.
  • Green: instructions to run the workflow.
  • Orange: you need to change something to make the workflow work.
  • Blue: draws attention to a key feature of the example.