Skip to main content

GitHub 提供商为用户和权限设置

¥GitHub provider setup for Users & Permissions

本页面说明如何为 用户和权限功能 设置 GitHub 提供程序。

¥The present page explains how to setup the GitHub provider for the Users & Permissions feature.

Prerequisites

你已阅读 用户和权限提供商文档

¥You have read the Users & Permissions providers documentation.

GitHub 配置

¥GitHub configuration

注意

Github 不接受 localhost 网址。
使用 ngrok 为后端应用提供服务。

¥Github doesn't accept localhost urls.
Use ngrok to serve the backend app.

ngrok http 1337

不要忘记使用生成的 ngrok URL 更新后端配置文件 config/server.js 中的服务器 URL 和前端应用中的服务器 URL(如果你使用 React 登录示例应用 ,则为环境变量 REACT_APP_BACKEND_URL)。

¥Don't forget to update the server url in the backend config file config/server.js and the server url in your frontend app (environment variable REACT_APP_BACKEND_URL if you use react login example app ) with the generated ngrok url.

  1. 访问 OAuth 应用列表页面 [https://github.com/settings/developers](https://github.com/settings/developers) 

    ¥Visit the OAuth Apps list page https://github.com/settings/developers 

  2. 单击新建 OAuth 应用按钮

    ¥Click on New OAuth App button

  3. 填写信息(替换为你自己的 ngrok url):

    ¥Fill the information (replace with your own ngrok url):

    • 应用名称:Strapi GitHub 授权

      ¥Application name: Strapi GitHub auth

    • 主页网址:https://65e60559.ngrok.io

      ¥Homepage URL: https://65e60559.ngrok.io

    • 应用说明:Strapi 提供者身份验证说明

      ¥Application description: Strapi provider auth description

    • 授权回调地址:https://65e60559.ngrok.io/api/connect/github/callback

      ¥Authorization callback URL: https://65e60559.ngrok.io/api/connect/github/callback

表带配置

¥Strapi configuration

  1. 访问用户和权限提供商设置页面位于 [http://localhost:1337/admin/settings/users-permissions/providers](http://localhost:1337/admin/settings/users-permissions/providers) 

    ¥Visit the User & Permissions provider settings page at http://localhost:1337/admin/settings/users-permissions/providers 

  2. 单击 GitHub 提供商

    ¥Click on the GitHub provider

  3. 填写信息(替换为你自己的客户端 ID 和密码):

    ¥Fill the information (replace with your own client ID and secret):

    • 使能够:ON

      ¥Enable: ON

    • 客户编号:53de5258f8472c140917

      ¥Client ID: 53de5258f8472c140917

    • 客户秘密:fb9d0fe1d345d9ac7f83d7a1e646b37c554dae8b

      ¥Client Secret: fb9d0fe1d345d9ac7f83d7a1e646b37c554dae8b

    • 前端应用的重定向 URL:http://localhost:3000/connect/github/redirect

      ¥The redirect URL to your front-end app: http://localhost:3000/connect/github/redirect

你的配置已完成。启动后端和 react login 示例应用 ,转到 http://localhost:3000 并尝试连接到你配置的提供商。

¥Your configuration is done. Launch the backend and the react login example application , go to http://localhost:3000 and try to connect to the provider you configured.