@logto/connector-github 1.0.0-beta.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -80
- package/lib/{src/constant.d.ts → constant.d.ts} +1 -1
- package/lib/{src/index.d.ts → index.d.ts} +2 -2
- package/lib/index.js +662 -15499
- package/lib/{src/types.d.ts → types.d.ts} +5 -5
- package/logo-dark.svg +8 -1
- package/logo.svg +8 -1
- package/package.json +42 -32
- package/docs/config-template.json +0 -4
- package/lib/jest.config.d.ts +0 -3
- package/lib/src/index.test.d.ts +0 -1
- /package/lib/{src/mock.d.ts → mock.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
The official Logto connector for GitHub social sign-in.
|
|
4
4
|
|
|
5
|
-
GitHub 社交登录 Logto 官方连接器 [中文文档](#github-连接器)
|
|
6
|
-
|
|
7
5
|
**Table of contents**
|
|
8
6
|
|
|
9
7
|
- [Github connector](#github-connector)
|
|
@@ -11,19 +9,10 @@ GitHub 社交登录 Logto 官方连接器 [中文文档](#github-连接器)
|
|
|
11
9
|
- [Sign in with GitHub account](#sign-in-with-github-account)
|
|
12
10
|
- [Create and configure OAuth app](#create-and-configure-oauth-app)
|
|
13
11
|
- [Managing OAuth apps](#managing-oauth-apps)
|
|
14
|
-
- [
|
|
12
|
+
- [Configure your connector](#configure-your-connector)
|
|
15
13
|
- [Config types](#config-types)
|
|
16
14
|
- [Test GitHub connector](#test-github-connector)
|
|
17
15
|
- [Reference](#reference)
|
|
18
|
-
- [GitHub 连接器](#github-连接器)
|
|
19
|
-
- [开始上手](#开始上手)
|
|
20
|
-
- [登录 GitHub 账号](#登录-github-账号)
|
|
21
|
-
- [创建并配置 OAuth 应用程序](#创建并配置-oauth-应用程序)
|
|
22
|
-
- [管理 OAuth 应用程序](#管理-oauth-应用程序)
|
|
23
|
-
- [编写连接器的 JSON](#编写连接器的-json)
|
|
24
|
-
- [配置类型](#配置类型)
|
|
25
|
-
- [测试 GitHub 连接器](#测试-github-连接器)
|
|
26
|
-
- [参考](#参考)
|
|
27
16
|
|
|
28
17
|
## Get started
|
|
29
18
|
|
|
@@ -38,7 +27,9 @@ Go to the [GitHub website](https://github.com/) and sign in with your GitHub acc
|
|
|
38
27
|
Follow the [creating an OAuth App](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app) guide, and register a new application.
|
|
39
28
|
|
|
40
29
|
Name your new OAuth application in **Application name** and fill up **Homepage URL** of the app.
|
|
41
|
-
You can leave **Application description** field blank and customize **Authorization callback URL** as `${your_logto_origin}/callback
|
|
30
|
+
You can leave **Application description** field blank and customize **Authorization callback URL** as `${your_logto_origin}/callback/${connector_id}`. The `connector_id` can be found on the top bar of the Logto Admin Console connector details page.
|
|
31
|
+
|
|
32
|
+
> Note: If you encounter the error message "The redirect_uri MUST match the registered callback URL for this application." when logging in, try aligning the Authorization Callback URL of your GitHub OAuth App and your Logto App's redirect URL (of course, including the protocol) to resolve the issue.
|
|
42
33
|
|
|
43
34
|
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](https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#device-flow).
|
|
44
35
|
|
|
@@ -47,19 +38,10 @@ We suggest not to check the box before **Enable Device Flow**, or users who sign
|
|
|
47
38
|
Go to the [OAuth Apps page](https://github.com/settings/developers) and you can add, edit or delete existing OAuth apps.
|
|
48
39
|
You can also find `Client ID` and generate `Client secrets` in OAuth app detail pages.
|
|
49
40
|
|
|
50
|
-
##
|
|
41
|
+
## Configure your connector
|
|
51
42
|
|
|
52
43
|
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.
|
|
53
44
|
|
|
54
|
-
Here is an example of GitHub connector config JSON.
|
|
55
|
-
|
|
56
|
-
```json
|
|
57
|
-
{
|
|
58
|
-
"clientID": "<your-client-id>",
|
|
59
|
-
"clientSecret": "<your-client-secret>"
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
45
|
### Config types
|
|
64
46
|
|
|
65
47
|
| Name | Type |
|
|
@@ -76,60 +58,3 @@ That's it. The GitHub connector should be available now. Don't forget to [Enable
|
|
|
76
58
|
|
|
77
59
|
- [GitHub - Developers - Apps](https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps)
|
|
78
60
|
- [GitHub - Developers - Apps - Creating an OAuth App](https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app)
|
|
79
|
-
|
|
80
|
-
# GitHub 连接器
|
|
81
|
-
|
|
82
|
-
## 开始上手
|
|
83
|
-
|
|
84
|
-
GitHub 连接器让终端用户可以用 GitHub 账号,通过 GitHub OAuth 2.0 授权协议来登录你的应用。
|
|
85
|
-
|
|
86
|
-
## 登录 GitHub 账号
|
|
87
|
-
|
|
88
|
-
前往 [GitHub 网站](https://github.com/) 并登录你的 GitHub 帐号。
|
|
89
|
-
|
|
90
|
-
## 创建并配置 OAuth 应用程序
|
|
91
|
-
|
|
92
|
-
跟随 [创建 _OAuth 应用程序_](https://docs.github.com/cn/developers/apps/building-oauth-apps/creating-an-oauth-app),注册一个新应用。
|
|
93
|
-
|
|
94
|
-
为新 _OAuth 应用程序_ 取名,并填入「Application name」栏;并填写应用的网页地址「Homepage URL」。
|
|
95
|
-
你需要将 `${your_logto_origin}/callback/github-universal` 填写到「Authorization callback URL」栏;「Application description」栏可以选择留白。
|
|
96
|
-
|
|
97
|
-
我们建议不要勾选「Enable Device Flow」,否则希望在移动设备上登录的用户需要在 GitHub 应用中确认登录的动作。许多 GitHub 用户在移动端设备上不会安装应用,这可能阻碍这些用户的登录流程。
|
|
98
|
-
|
|
99
|
-
如果你的确期望终端用户在移动设备上需要有确认登录的动作,请忽略我们的建议。查看更多关于 [设备流程](https://docs.github.com/cn/developers/apps/building-oauth-apps/authorizing-oauth-apps#device-flow) 的详情。
|
|
100
|
-
|
|
101
|
-
## 管理 OAuth 应用程序
|
|
102
|
-
|
|
103
|
-
前往 [OAuth Apps](https://github.com/settings/developers),你可以添加新应用或者修改、删除已存在的 _OAuth 应用程序_。
|
|
104
|
-
|
|
105
|
-
在应用详情页,你能找到 `Client ID` 和 `Client secrets`(如果没有可以点击「Generate a new client secret」生成新的)。
|
|
106
|
-
|
|
107
|
-
## 编写连接器的 JSON
|
|
108
|
-
|
|
109
|
-
用你从上一步 OAuth 应用程序详情页获取到的 _Client ID_ 和 _Client Secret_ 分别填写 `clientId` 和 `clientSecret`。
|
|
110
|
-
|
|
111
|
-
以下是一个 GitHub 连接器配置 JSON 的样例。
|
|
112
|
-
|
|
113
|
-
```json
|
|
114
|
-
{
|
|
115
|
-
"clientID": "<your-client-id>",
|
|
116
|
-
"clientSecret": "<your-client-secret>"
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### 配置类型
|
|
121
|
-
|
|
122
|
-
| 名称 | 类型 |
|
|
123
|
-
|--------------|--------|
|
|
124
|
-
| clientId | string |
|
|
125
|
-
| clientSecret | string |
|
|
126
|
-
|
|
127
|
-
## 测试 GitHub 连接器
|
|
128
|
-
|
|
129
|
-
大功告成!GitHub 连接器现在可以正常使用了。
|
|
130
|
-
别忘了 [在登录体验中启用本连接器](https://docs.logto.io/zh-cn/docs/tutorials/get-started/enable-social-sign-in/#%E5%9C%A8%E7%99%BB%E5%BD%95%E4%BD%93%E9%AA%8C%E4%B8%AD%E5%90%AF%E7%94%A8%E8%BF%9E%E6%8E%A5%E5%99%A8)。
|
|
131
|
-
|
|
132
|
-
## 参考
|
|
133
|
-
|
|
134
|
-
- [GitHub - 开发者 - 应用](https://docs.github.com/cn/developers/apps/getting-started-with-apps/about-apps)
|
|
135
|
-
- [GitHub - 开发者 - 应用 - 创建 OAuth 应用程序](https://docs.github.com/cn/developers/apps/building-oauth-apps/creating-an-oauth-app)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectorMetadata } from '@logto/connector-
|
|
1
|
+
import type { ConnectorMetadata } from '@logto/connector-kit';
|
|
2
2
|
export declare const authorizationEndpoint = "https://github.com/login/oauth/authorize";
|
|
3
3
|
export declare const scope = "read:user";
|
|
4
4
|
export declare const accessTokenEndpoint = "https://github.com/login/oauth/access_token";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SocialConnector, CreateConnector } from '@logto/connector-
|
|
2
|
-
import { GithubConfig } from './types';
|
|
1
|
+
import type { SocialConnector, CreateConnector } from '@logto/connector-kit';
|
|
2
|
+
import type { GithubConfig } from './types.js';
|
|
3
3
|
export declare const getAccessToken: (config: GithubConfig, codeObject: {
|
|
4
4
|
code: string;
|
|
5
5
|
}) => Promise<{
|