0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-23 20:33:16 -05:00
logto/packages/connector-github
2022-07-19 01:05:03 +00:00
..
docs chore(connectors): config template md files to json files (#987) 2022-05-31 12:58:24 +08:00
src chore(connector): update connector description (#1591) 2022-07-18 11:51:17 +00:00
CHANGELOG.md release: v1.0.0-beta.1 2022-07-19 01:05:03 +00:00
jest.config.ts refactor: use @silverhand/jest-config (#861) 2022-05-17 17:32:41 +08:00
logo-dark.svg feat(core,connectors): update Aliyun logo and add logo_dark to Apple, Github (#1194) 2022-06-23 11:12:29 +08:00
logo.svg feat(core): serve connector logo (#931) 2022-05-24 13:54:37 +08:00
package.json release: v1.0.0-beta.1 2022-07-19 01:05:03 +00:00
README.md docs(connector): add github readme zh-CN (#1583) 2022-07-18 11:35:34 +00:00
tsconfig.base.json feat(core): wrap github connector (#673) 2022-04-28 15:01:55 +08:00
tsconfig.build.json feat(core): wrap github connector (#673) 2022-04-28 15:01:55 +08:00
tsconfig.json feat(core): wrap github connector (#673) 2022-04-28 15:01:55 +08:00
tsconfig.test.json test: allow JS in tests (#903) 2022-05-20 13:02:36 +08:00

Github connector

The official Logto connector for GitHub social sign-in.

GitHub 社交登录 Logto 官方连接器 中文文档

Table of contents

Get started

The GitHub connector enables end-users to sign in to your application using their own GitHub accounts via GitHub OAuth 2.0 authentication protocol.

Sign in with GitHub account

Go to the GitHub website and sign in with your GitHub account. You may register a new account if you don't have one.

Create and configure OAuth app

Follow the creating an OAuth App guide, and register a new application.

Name your new OAuth application in Application name and fill up Homepage URL of the app. You can leave Application description field blank and customize Authorization callback URL as ${your_logto_origin}/callback/github-universal.

We suggest not to check the box before Enable Device Flow, or users who sign in with GitHub on mobile devices must confirm the initial sign-in action in the GitHub app. Many GitHub users do not install the GitHub mobile app on their phones, which could block the sign-in flow. Please ignore our suggestion if you are expecting end-users to confirm their sign-in flow. See details of device flow.

Managing OAuth apps

Go to the OAuth Apps page and you can add, edit or delete existing OAuth apps. You can also find Client ID and generate Client secrets in OAuth app detail pages.

Compose the connector JSON

Fill out the clientId and clientSecret field with Client ID and Client Secret you've got from OAuth app detail pages mentioned in the previous section.

Here is an example of GitHub connector config JSON.

{
  "clientID": "<your-client-id>",
  "clientSecret": "<your-client-secret>"
}

Config types

Name Type
clientId string
clientSecret string

Test GitHub connector

That's it. The GitHub connector should be available now. Don't forget to Enable connector in sign-in experience.

Reference

GitHub 连接器

开始上手

GitHub 连接器让终端用户可以用 GitHub 账号,通过 GitHub OAuth 2.0 授权协议来登录你的应用。

登录 GitHub 账号

前往 GitHub 网站 并登录你的 GitHub 帐号。

创建并配置 OAuth 应用程序

跟随 创建 OAuth 应用程序,注册一个新应用。

为新 OAuth 应用程序 取名并填入「Application name」栏并填写应用的网页地址「Homepage URL」。 你需要将 ${your_logto_origin}/callback/github-universal 填写到「Authorization callback URL」栏「Application description」栏可以选择留白。

我们建议不要勾选「Enable Device Flow」否则希望在移动设备上登录的用户需要在 GitHub 应用中确认登录的动作。许多 GitHub 用户在移动端设备上不会安装应用,这可能阻碍这些用户的登录流程。

如果你的确期望终端用户在移动设备上需要有确认登录的动作,请忽略我们的建议。查看更多关于 设备流程 的详情。

管理 OAuth 应用程序

前往 OAuth Apps,你可以添加新应用或者修改、删除已存在的 OAuth 应用程序

在应用详情页,你能找到 Client IDClient secrets如果没有可以点击「Generate a new client secret」生成新的

编写连接器的 JSON

用你从上一步 OAuth 应用程序详情页获取到的 Client IDClient Secret 分别填写 clientIdclientSecret

以下是一个 GitHub 连接器配置 JSON 的样例。

{
  "clientID": "<your-client-id>",
  "clientSecret": "<your-client-secret>"
}

配置类型

名称 类型
clientId string
clientSecret string

测试 GitHub 连接器

大功告成GitHub 连接器现在可以正常使用了。 别忘了 在登录体验中启用本连接器

参考