@logto/connector-github 1.0.0-beta.18 → 1.0.0-beta.20
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 +4 -79
- package/lib/index.js +17 -2
- package/logo-dark.svg +8 -1
- package/logo.svg +8 -1
- package/package.json +2 -2
- package/docs/config-template.json +0 -4
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
|
|
|
@@ -40,6 +29,8 @@ Follow the [creating an OAuth App](https://docs.github.com/en/developers/apps/bu
|
|
|
40
29
|
Name your new OAuth application in **Application name** and fill up **Homepage URL** of the app.
|
|
41
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.
|
|
42
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.
|
|
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
|
|
|
45
36
|
## Managing OAuth apps
|
|
@@ -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/${connector_id}` 填写到「Authorization callback URL」栏;「Application description」栏可以选择留白。`connector_id` 在管理控制台相应连接器的详情页的顶栏中可以找到。
|
|
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)
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConnectorPlatform, ConnectorError, ConnectorErrorCodes, ConnectorType, validateConfig, parseJson } from '@logto/connector-kit';
|
|
1
|
+
import { ConnectorPlatform, ConnectorConfigFormItemType, ConnectorError, ConnectorErrorCodes, ConnectorType, validateConfig, parseJson } from '@logto/connector-kit';
|
|
2
2
|
import { got, HTTPError } from 'got';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -660,7 +660,22 @@ const defaultMetadata = {
|
|
|
660
660
|
ko: 'GitHub는 소프트웨어 개발과 버전 관리를 위한 온라인 커뮤니티입니다.',
|
|
661
661
|
},
|
|
662
662
|
readme: './README.md',
|
|
663
|
-
|
|
663
|
+
formItems: [
|
|
664
|
+
{
|
|
665
|
+
key: 'clientId',
|
|
666
|
+
type: ConnectorConfigFormItemType.Text,
|
|
667
|
+
label: 'Client ID',
|
|
668
|
+
required: true,
|
|
669
|
+
placeholder: '<client-id>',
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
key: 'clientSecret',
|
|
673
|
+
type: ConnectorConfigFormItemType.Text,
|
|
674
|
+
label: 'Client Secret',
|
|
675
|
+
required: true,
|
|
676
|
+
placeholder: '<client-secret>',
|
|
677
|
+
},
|
|
678
|
+
],
|
|
664
679
|
};
|
|
665
680
|
const defaultTimeout = 5000;
|
|
666
681
|
|
package/logo-dark.svg
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path
|
|
2
|
+
<g clip-path="url(#clip0_865_12456)">
|
|
3
|
+
<path d="M11.9999 0.300049C9.15054 0.300167 6.39414 1.31419 4.22396 3.16068C2.05378 5.00717 0.61143 7.56562 0.154992 10.3783C-0.301447 13.1909 0.257812 16.0742 1.7327 18.5122C3.20759 20.9503 5.50186 22.7839 8.205 23.6851C8.80499 23.7902 9.02999 23.4302 9.02999 23.1151C9.02999 22.8301 9.01498 21.8851 9.01498 20.8801C5.99999 21.4351 5.22 20.1452 4.98 19.4702C4.71369 18.8137 4.29153 18.2319 3.75001 17.7751C3.33001 17.5501 2.73001 16.9951 3.73499 16.9801C4.11874 17.0218 4.48679 17.1553 4.80796 17.3694C5.12913 17.5835 5.39395 17.8719 5.57999 18.2101C5.74412 18.505 5.96481 18.7645 6.22942 18.9739C6.49403 19.1833 6.79736 19.3384 7.12202 19.4304C7.44669 19.5224 7.78631 19.5494 8.12143 19.5099C8.45655 19.4703 8.78058 19.3651 9.07494 19.2001C9.12689 18.5901 9.39877 18.0197 9.83996 17.5952C7.16998 17.2952 4.38 16.2601 4.38 11.6701C4.36314 10.4775 4.80322 9.32362 5.60999 8.44512C5.24313 7.40858 5.28606 6.27105 5.72999 5.26511C5.72999 5.26511 6.73495 4.95009 9.02997 6.49511C10.9935 5.95508 13.0664 5.95508 15.0299 6.49511C17.3249 4.9351 18.3299 5.26511 18.3299 5.26511C18.7739 6.27104 18.8168 7.40859 18.4499 8.44512C19.2591 9.32211 19.6996 10.477 19.6799 11.6701C19.6799 16.2751 16.8749 17.2952 14.2049 17.5952C14.4913 17.8854 14.7119 18.2339 14.8516 18.617C14.9914 19 15.0471 19.4087 15.0149 19.8152C15.0149 21.4202 14.9999 22.7102 14.9999 23.1152C14.9999 23.4302 15.2249 23.8052 15.8249 23.6852C18.5233 22.7766 20.811 20.9387 22.2796 18.4994C23.7482 16.0601 24.3021 13.1783 23.8425 10.3684C23.3829 7.55845 21.9397 5.00331 19.7705 3.15907C17.6012 1.31483 14.8472 0.301531 11.9999 0.300049Z" fill="white"/>
|
|
4
|
+
</g>
|
|
5
|
+
<defs>
|
|
6
|
+
<clipPath id="clip0_865_12456">
|
|
7
|
+
<rect width="24" height="24" fill="white"/>
|
|
8
|
+
</clipPath>
|
|
9
|
+
</defs>
|
|
3
10
|
</svg>
|
package/logo.svg
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path
|
|
2
|
+
<g clip-path="url(#clip0_865_12254)">
|
|
3
|
+
<path d="M11.9999 0.296021C9.15054 0.296139 6.39414 1.31016 4.22396 3.15665C2.05378 5.00314 0.61143 7.5616 0.154992 10.3742C-0.301447 13.1869 0.257812 16.0702 1.7327 18.5082C3.20759 20.9462 5.50186 22.7799 8.205 23.6811C8.80499 23.7861 9.02999 23.4261 9.02999 23.1111C9.02999 22.8261 9.01498 21.8811 9.01498 20.8761C5.99999 21.4311 5.22 20.1411 4.98 19.4661C4.71369 18.8096 4.29153 18.2279 3.75001 17.7711C3.33001 17.5461 2.73001 16.9911 3.73499 16.9761C4.11874 17.0178 4.48679 17.1513 4.80796 17.3654C5.12913 17.5795 5.39395 17.8679 5.57999 18.2061C5.74412 18.5009 5.96481 18.7605 6.22942 18.9699C6.49403 19.1793 6.79736 19.3344 7.12202 19.4264C7.44669 19.5183 7.78631 19.5453 8.12143 19.5058C8.45655 19.4663 8.78058 19.3611 9.07494 19.1961C9.12689 18.586 9.39877 18.0156 9.83996 17.5911C7.16998 17.2911 4.38 16.2561 4.38 11.6661C4.36314 10.4735 4.80322 9.31959 5.60999 8.44109C5.24313 7.40455 5.28606 6.26702 5.72999 5.26108C5.72999 5.26108 6.73495 4.94606 9.02997 6.49108C10.9935 5.95105 13.0664 5.95105 15.0299 6.49108C17.3249 4.93108 18.3299 5.26108 18.3299 5.26108C18.7739 6.26701 18.8168 7.40456 18.4499 8.44109C19.2591 9.31808 19.6996 10.473 19.6799 11.6661C19.6799 16.2711 16.8749 17.2911 14.2049 17.5911C14.4913 17.8814 14.7119 18.2299 14.8516 18.6129C14.9914 18.996 15.0471 19.4046 15.0149 19.8111C15.0149 21.4162 14.9999 22.7061 14.9999 23.1112C14.9999 23.4262 15.2249 23.8012 15.8249 23.6812C18.5233 22.7726 20.811 20.9346 22.2796 18.4954C23.7482 16.0561 24.3021 13.1743 23.8425 10.3643C23.3829 7.55442 21.9397 4.99929 19.7705 3.15505C17.6012 1.31081 14.8472 0.297502 11.9999 0.296021Z" fill="black"/>
|
|
4
|
+
</g>
|
|
5
|
+
<defs>
|
|
6
|
+
<clipPath id="clip0_865_12254">
|
|
7
|
+
<rect width="24" height="24" fill="white"/>
|
|
8
|
+
</clipPath>
|
|
9
|
+
</defs>
|
|
3
10
|
</svg>
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"logo-dark.svg"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@logto/connector-kit": "1.0.0-rc.
|
|
14
|
+
"@logto/connector-kit": "1.0.0-rc.2",
|
|
15
15
|
"@silverhand/essentials": "2.1.0",
|
|
16
16
|
"got": "^12.5.3",
|
|
17
17
|
"snakecase-keys": "^5.1.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"name": "@logto/connector-github",
|
|
55
|
-
"version": "1.0.0-beta.
|
|
55
|
+
"version": "1.0.0-beta.20",
|
|
56
56
|
"description": "Github web connector implementation.",
|
|
57
57
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
58
58
|
"scripts": {
|