Skip to content

Strapi 凭证#

¥Strapi credentials

你可以使用以下凭据验证以下节点:

¥You can use these credentials to authenticate the following nodes:

先决条件#

¥Prerequisites

创建具有以下权限的 Strapi 管理员账户:

¥Create a Strapi admin account with:

  • 访问现有的 Strapi 项目。

¥Access to an existing Strapi project.

  • 该项目中至少包含一种集合类型。

¥At least one collection type within that project.

  • 已发布该集合类型的数据。

¥Published data within that collection type.

请参阅 Strapi 开发者 快速入门指南 文档了解更多信息。

¥Refer to the Strapi developer Quick Start Guide for more information.

支持的身份验证方法#

¥Supported authentication methods

  • API 用户账户:需要具有相应内容权限的用户账户。

¥API user account: Requires a user account with appropriate content permissions.

  • API 令牌:需要管理员账户。

¥API token: Requires an admin account.

相关资源#

¥Related resources

有关服务的更多信息,请参阅 Strapi 文档

¥Refer to Strapi's documentation for more information about the service.

使用 API 用户账户#

¥Using API user account

要配置此凭据,你需要:

¥To configure this credential, you'll need:

  • 用户邮箱:必须是用户账户,而非管理员账户。请参阅以下各部分,了解更多详细说明。

¥A user Email: Must be for a user account, not an admin account. Refer to the more detailed instructions below.

  • 用户密码:必须是用户账户,而非管理员账户。请参阅以下各部分,了解更多详细说明。

¥A user Password: Must be for a user account, not an admin account. Refer to the more detailed instructions below.

  • URL:使用 Strapi 服务器的公共 URL,该 URL 在 ./config/server.js 中定义为 url 参数。Strapi 建议使用绝对 URL。

¥The URL: Use the public URL of your Strapi server, defined in ./config/server.js as the url parameter. Strapi recommends using an absolute URL.

  • 对于 Strapi 云项目,请使用你的云项目 URL,例如:https://my-strapi-project-name.strapiapp.com

    ¥For Strapi Cloud projects, use the URL of your Cloud project, for example: https://my-strapi-project-name.strapiapp.com

  • API 版本:选择你希望调用使用的 API 版本。选项包括:

¥The API Version: Select the version of the API you want your calls to use. Options include:

  • 版本 3

    ¥Version 3

  • 版本 4

    ¥Version 4

在 Strapi 中,配置包含两个步骤:

¥In Strapi, the configuration involves two steps:

  1. 配置角色

¥Configure a role. 2. 创建用户帐号

¥Create a user account.

请参阅以下各步骤的详细说明。

¥Refer to the more detailed instructions below for each step.

配置角色#

¥Configure a role

要访问 API,请使用“设置”>“用户和权限插件”中的“用户和权限插件”。

¥For API access, use the Users & Permissions Plugin in Settings > Users & Permissions Plugin.

有关插件的更多信息,请参阅 配置用户和权限插件。有关角色的更多信息,请参阅 配置终端用户角色

¥Refer to Configuring Users & Permissions Plugin for more information on the plugin. Refer to Configuring end-user roles for more information on roles.

对于 n8n 凭据,用户必须拥有授予其对集合类型 API 权限的角色。对于角色,你可以选择:

¥For the n8n credential, the user must have a role that grants them API permissions on the collection type. For the role, you can either:

  • 更新默认的“已验证”角色,使其包含相应的权限,并将用户分配到该角色。有关更多信息,请参阅 配置角色权限

¥Update the default Authenticated role to include the permissions and assign the user to that role. Refer to Configuring role's permissions for more information.

  • 创建一个包含权限的新角色,并将用户分配给该角色。有关更多信息,请参阅 创建新的角色

¥Create a new role to include the permissions and assign the user to that role. Refer to Creating a new role for more information.

对于任一选项,打开角色后:

¥For either option, once you open the role:

  1. 前往权限部分。

¥Go to the Permissions section. 2. 打开相关集合类型的部分。

¥Open the section for the relevant collection type. 3. 选择角色应具有的集合类型的权限。选项包括:

¥Select the permissions for the collection type that the role should have. Options include:

  • create(POST)

  • findfindone(GET 请求)

    ¥find and findone (GET)

  • update(PUT)

  • delete(DELETE) 4. 对所有相关的集合类型重复此操作。

¥Repeat for all relevant collection types. 5. 保存角色。

¥Save the role.

有关权限选项的更多信息,请参阅 端点

¥Refer to Endpoints for more information on the permission options.

创建用户帐号#

¥Create a user account

既然你已经拥有了合适的角色,请创建一个终端用户账户并将该角色分配给它:

¥Now that you have an appropriate role, create an end-user account and assign the role to it:

  1. 前往“内容管理器”>“集合类型”>“用户”。

¥Go to Content Manager > Collection Types > User. 2. 选择添加新条目。

¥Select Add new entry. 3. 填写用户详细信息。n8n 凭证需要以下字段,但你的 Strapi 项目可能包含更多自定义的必填字段:

¥Fill in the user details. The n8n credential requires these fields, though your Strapi project may have more custom required fields:

  • 用户名:所有 Strapi 用户都需要此字段。

    ¥Username: Required for all Strapi users.

  • 邮件:在 Strapi 中输入,并将其用作 n8n 凭证中的电子邮件地址。

    ¥Email: Enter in Strapi and use as the Email in the n8n credential.

  • 密码:在 Strapi 中输入,并将其用作 n8n 凭证中的密码。

    ¥Password: Enter in Strapi and use as the Password in the n8n credential.

  • 角色:选择你在上一步中设置的角色。

    ¥Role: Select the role you set up in the previous step.

有关更多信息,请参阅 管理终端用户账户

¥Refer to Managing end-user accounts for more information.

使用 API 令牌#

¥Using API token

要配置此凭据,你需要:

¥To configure this credential, you'll need:

  • API 令牌:从“设置”>“全局设置”>“API 令牌”创建 API 令牌。有关 API 令牌重新生成的更多信息,请参阅 Strapi 的 创建新的 API 令牌文档

¥An API Token: Create an API token from Settings > Global Settings > API Tokens. Refer to Strapi's Creating a new API token documentation for more details and information on regenerating API tokens.

API tokens permission

1
If you don't see the **API tokens** option in **Global settings**, your account doesn't have the **API tokens > Read** permission.
  • URL:使用 Strapi 服务器的公共 URL,该 URL 在 ./config/server.js 中定义为 url 参数。Strapi 建议使用绝对 URL。

¥The URL: Use the public URL of your Strapi server, defined in ./config/server.js as the url parameter. Strapi recommends using an absolute URL.

  • 对于 Strapi 云项目,请使用你的云项目 URL,例如:https://my-strapi-project-name.strapiapp.com

    ¥For Strapi Cloud projects, use the URL of your Cloud project, for example: https://my-strapi-project-name.strapiapp.com

  • API 版本:选择你希望调用使用的 API 版本。选项包括:

¥The API Version: Select the version of the API you want your calls to use. Options include:

  • 版本 3

    ¥Version 3

  • 版本 4

    ¥Version 4