Strapi 凭证(Strapi credentials)#
你可以使用以下凭据验证以下节点:
🌐 You can use these credentials to authenticate the following nodes:
先决条件(Prerequisites)#
创建一个 Strapi 管理员账户,使用:
🌐 Create a Strapi admin account with:
- 访问现有的 Strapi 项目。
- 该项目中至少包含一种集合类型。
- 已发布该集合类型的数据。
有关更多信息,请参阅 Strapi 开发者 快速入门指南 。
🌐 Refer to the Strapi developer Quick Start Guide for more information.
支持的身份验证方法(Supported authentication methods)#
- API 用户账户:需要具有相应内容权限的用户账户。
- API 令牌:需要管理员账户。
相关资源(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:
- 用户电子邮件:必须是用户账户的电子邮件,而不是管理员账户的电子邮件。请参阅下面更详细的说明。
- 用户密码:必须用于普通用户账户,而非管理员账户。请参阅下面更详细的说明。
- URL:使用 Strapi 服务器的公共 URL,在
./config/server.js中定义为url参数。Strapi 建议使用绝对 URL。- 对于 Strapi Cloud 项目,请使用你的 Cloud 项目的 URL,例如:
https://my-strapi-project-name.strapiapp.com
- 对于 Strapi Cloud 项目,请使用你的 Cloud 项目的 URL,例如:
- API 版本:选择你希望调用使用的 API 版本。选项包括:
- 版本 3
- 版本 4
在 Strapi 中,配置包含两个步骤:
🌐 In Strapi, the configuration involves two steps:
请参阅以下各步骤的详细说明。
🌐 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:
对于任一选项,打开角色后:
🌐 For either option, once you open the role:
- 进入权限部分。
- 打开相关集合类型的部分。
- 选择该角色应拥有的集合类型权限。选项包括:
create(POST)find和findone(获取)update(放置)delete(删除)
- 对所有相关的集合类型重复此操作。
- 保存角色。
有关权限选项的更多信息,请参阅 Endpoints。
🌐 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:
- 转到 内容管理器 > 集合类型 > 用户。
- 选择 添加新条目。
- 填写用户详细信息。n8n 凭证需要这些字段,尽管你的 Strapi 项目可能还有更多自定义必填字段:
- 用户名:所有 Strapi 用户必填。
- 电子邮件:在 Strapi 中输入,并作为 n8n 凭证中的 电子邮件 使用。
- 密码:在 Strapi 中输入,并在 n8n 凭证中作为 密码 使用。
- 角色:选择你在上一步中设置的角色。
有关更多信息,请参阅 管理终端用户账户。
🌐 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 令牌文档。
API 令牌权限
如果你在 全局设置 中看不到 API 令牌 选项,说明你的账户没有 API 令牌 > 读取 权限。
-
URL:使用 Strapi 服务器的公共 URL,在
./config/server.js中定义为url参数。Strapi 建议使用绝对 URL。- 对于 Strapi Cloud 项目,请使用你的 Cloud 项目的 URL,例如:
https://my-strapi-project-name.strapiapp.com
- 对于 Strapi Cloud 项目,请使用你的 Cloud 项目的 URL,例如:
- API 版本:选择你希望调用使用的 API 版本。选项包括:
- 版本 3
- 版本 4