# 为用户和权限设置 Auth0 提供程序

> Source: https://strapi.nodejs.cn/cms/configurations/users-and-permissions-providers/auth-zero

🌐 Auth0 provider setup for Users & Permissions

Auth0 提供程序设置为用户与权限功能启用 OAuth 2.0 身份验证，需要在 Auth0 租户和 Strapi 管理设置中使用客户端 ID、客户端密钥和子域凭据进行配置。

🌐 Auth0 provider setup enables OAuth 2.0 authentication for the Users & Permissions feature, requiring configuration in both Auth0 tenant and Strapi admin settings using Client ID, Client Secret, and subdomain credentials.

本页解释了如何为[用户与权限功能](/cms/features/users-permissions)设置 Auth0 提供程序。

🌐 The present page explains how to setup the Auth0 provider for the [Users & Permissions feature](/cms/features/users-permissions).

:::prerequisites

你已阅读 [用户与权限提供程序文档](/cms/configurations/users-and-permissions-providers)。

🌐 You have read the [Users & Permissions providers documentation](/cms/configurations/users-and-permissions-providers).

:::

## Auth0 配置 {#auth0-configuration}

🌐 Auth0 configuration

:::note

Auth0 接受 `localhost` URL。 <br/>
不需要使用 `ngrok`。

:::

1. 访问你的 Auth0 租户仪表板
2. 在 API 部分，创建一个新的 API
3. 在应用中，创建一个 `machine-to-machine` 应用并选择你刚刚创建的 API
4. 在此应用的设置中设置以下值：
   - **允许的回调 URL**：`http://localhost:1337/api/connect/auth0/callback`
   - **允许的退出登录 URL**：`http://localhost:3000`
   - **允许的网页来源**: `http://localhost:3000`
5. 在设置底部，显示“高级设置”并进入“授权类型”。确保勾选/启用这些授权：
   - 隐含的
   - 授权码
   - 刷新令牌
   - 客户端凭据

## Strapi 配置 {#strapi-configuration}

🌐 Strapi configuration

1. 访问用户与权限提供程序设置页面，网址为 [http://localhost:1337/admin/settings/users-permissions/providers](http://localhost:1337/admin/settings/users-permissions/providers)
2. 点击 **Auth0** 提供商
3. 填写信息：
   - 启用：`ON`
   - 客户ID：`<Your Auth0 Client ID>`
   - 客户端密钥：`<Your Auth0 Client Secret>`
   - 子域名：`<Your Auth0 tenant url>`，例如，它是在以下网址中加粗的部分：https://**my-tenant.eu**.auth0.com/
   - 重定向到你的前端应用的 URL：`http://localhost:3000/connect/auth0`

你的配置已完成。启动后端和 [react login example application](https://github.com/strapi/strapi-examples/tree/master/examples/login-react)，转到`http://localhost:3000`并尝试连接你配置的提供程序。
