.. | ||
docs | ||
src | ||
CHANGELOG.md | ||
jest.config.ts | ||
logo-dark.svg | ||
logo.svg | ||
package.json | ||
README.md | ||
tsconfig.base.json | ||
tsconfig.build.json | ||
tsconfig.json | ||
tsconfig.test.json |
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 ID
和 Client secrets
(如果没有可以点击「Generate a new client secret」生成新的)。
编写连接器的 JSON
用你从上一步 OAuth 应用程序详情页获取到的 Client ID 和 Client Secret 分别填写 clientId
和 clientSecret
。
以下是一个 GitHub 连接器配置 JSON 的样例。
{
"clientID": "<your-client-id>",
"clientSecret": "<your-client-secret>"
}
配置类型
名称 | 类型 |
---|---|
clientId | string |
clientSecret | string |
测试 GitHub 连接器
大功告成!GitHub 连接器现在可以正常使用了。 别忘了 在登录体验中启用本连接器。