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. 选择侧边菜单左上角的“创建”按钮。选择凭据。

¥Select the {.off-glb} Create button in the upper-left corner of the side menu. Select credential. 2. 如果你的 n8n 实例支持 projects,你还需要选择是在个人空间还是在你有权访问的特定项目中创建凭据。如果你使用的是社区版,则需要在你的个人空间内创建凭据。

¥If your n8n instance supports projects, you'll also need to choose whether to create the credential inside your personal space or a specific project you have access to. If you're using the community version, you'll create the credential inside your personal space. 3. 选择要连接的应用或服务。

¥Select the app or service you wish to connect to.

或:

¥Or:

  1. 使用概览页面或特定项目右上角的 universal create resource icon 创建按钮。选择凭据。

¥Using the {.off-glb} Create button in the upper-right corner from either the Overview page or a specific project. Select Credential. 2. 如果你从“概览”页面执行此操作,则需要在你的个人空间中创建凭据。如果你在项目内部执行此操作,则需要在该特定项目中创建凭据。

¥If you're doing this from the Overview page, you'll create the credential inside your personal space. If you're doing this from inside a project, you'll create the credential inside that specific project. 3. 选择要连接的应用或服务。

¥Select the app or service you wish to connect to.

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

¥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.

Credentials naming

n8n 默认将新凭据命名为 "节点名称账户"。你可以点击名称来重命名凭据,操作方式与重命名节点类似。最佳实践是为凭据命名,以便识别应用或服务、类型和用途。命名约定有助于你更轻松地跟踪和识别凭据。

¥n8n names new credentials "node name account" by default. You can rename the credentials by clicking on the name, similarly to renaming nodes. It's good practice to give them names that identify the app or service, type, and purpose of the credential. A naming convention makes it easier to keep track of and identify your credentials.

凭据中的表达式#

¥Expressions in credentials

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

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

  1. 在你的工作流中,找到包含凭据的数据路径。此值取决于数据中具体的参数名称。请确保在到达需要凭据的节点时,包含凭据的数据在工作流中可用。

¥In your workflow, find the data path containing the credential. This varies depending on the exact parameter names in your data. Make sure that the data containing the credential is available in the workflow when you get to the node that needs it. 2. 创建凭证时,将鼠标悬停在要使用表达式的字段上。

¥When creating your credential, hover over the field where you want to use an expression. 3. 启用表达式。

¥Toggle Expression on. 4. 输入你的表达式。

¥Enter your expression.

示例工作流程#

¥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.