Skip to content

Commit 2f8f9d6

Browse files
authored
feat(connector): add QQ connector (#7380)
* feat: add QQ social connector for Web. Refs #6769 Signed-off-by: Yen Harvey <[email protected]> * test: fix QQ connector tests Signed-off-by: Yen Harvey <[email protected]> * chore: add changeset for QQ connector Signed-off-by: Yen Harvey <[email protected]> * feat: optimize QQ connector logo SVG size * docs: add detailed API comments and optimize documentation * docs: update heading format to sentence case and refine documentation * chore: update package.json and pnpm lockfile for consistency --------- Signed-off-by: Yen Harvey <[email protected]>
1 parent 8931776 commit 2f8f9d6

File tree

11 files changed

+850
-9
lines changed

11 files changed

+850
-9
lines changed

.changeset/red-rules-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@logto/connector-qq": major
3+
---
4+
5+
add QQ social connector for web
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# QQ social connector
2+
3+
The official Logto connector for QQ social sign-in [中文文档](https://github.com/logto-io/logto/tree/master/packages/connectors/connector-qq/README.zh-CN.md)
4+
5+
**Table of Contents**
6+
7+
- [QQ social connector](#qq-social-connector)
8+
- [Get started](#get-started)
9+
- [Configure QQ Connect application](#configure-qq-connect-application)
10+
- [Permission requirements](#permission-requirements)
11+
- [Test QQ connector](#test-qq-connector)
12+
- [References](#references)
13+
14+
QQ is a social platform by Tencent with over 600 million users. This connector helps end-users sign in to your application using their QQ accounts.
15+
16+
## Get started
17+
18+
1. Create a developer account on [QQ Connect platform](https://connect.qq.com/)
19+
2. Access the [Application Management](https://connect.qq.com/manage.html)
20+
3. Create a new application (if you don't already have one)
21+
22+
## Configure QQ Connect application
23+
24+
1. Access the [Application Management](https://connect.qq.com/manage.html)
25+
2. Configure the OAuth settings:
26+
- Open the application you want to use for sign-in, and click on "Application Info"
27+
- Add "Website Callback Domain": `logto_endpoint`
28+
- Add "Website Callback URL" : `${logto_endpoint}/callback/${connector_id}`
29+
3. Get the `APP ID` and `APP Key` from the application info page
30+
4. Fill in the values from step 3 to the `clientId` and `clientSecret` fields in the Logto Admin Console
31+
32+
## Permission requirements
33+
34+
To use this connector, you need to apply for the following permissions on the QQ Connect platform:
35+
36+
1. **UnionID Permission**: You must apply for the UnionID API permission to ensure we can obtain the user's unique identifier.
37+
Please apply for this permission through the [QQ Connect platform](https://connect.qq.com/).
38+
39+
2. **Default scope**: `get_user_info`
40+
This is used to obtain the user's basic information, such as nickname and avatar.
41+
By default, if no scope parameter is set, the system will use this permission.
42+
43+
## Test QQ connector
44+
45+
That's it! Don't forget to enable the connector in the [Sign-in Experience](https://{logto_endpoint}/console/connectors/social).
46+
47+
## References
48+
49+
- [QQ Connect Integration Guide](https://wiki.connect.qq.com/%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C_oauth2-0)
50+
- [QQ Open Platform API Documentation](https://wiki.connect.qq.com/)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# QQ社交连接器
2+
3+
QQ社交登录 Logto 官方连接器 [English Documentation](https://github.com/logto-io/logto/tree/master/packages/connectors/connector-qq/README.md)
4+
5+
**目录**
6+
7+
- [QQ社交连接器](#qq社交连接器)
8+
- [开始上手](#开始上手)
9+
- [配置QQ Connect应用](#配置qq-connect应用)
10+
- [权限要求](#权限要求)
11+
- [测试QQ连接器](#测试qq连接器)
12+
- [参考](#参考)
13+
14+
QQ是腾讯旗下的社交平台,拥有超过6亿用户。本连接器可以帮助终端用户使用QQ账号登录你的应用。
15+
16+
## 开始上手
17+
18+
1.[QQ互联平台](https://connect.qq.com/)创建开发者账号
19+
2. 访问[应用管理](https://connect.qq.com/manage.html)
20+
3. 创建一个新应用(如果还没有)
21+
22+
## 配置QQ Connect应用
23+
24+
1. 访问[应用管理](https://connect.qq.com/manage.html)
25+
2. 配置应用设置:
26+
- 打开要用于登录的应用,点击「应用信息」
27+
- 添加「网站地址」: `logto_endpoint`
28+
- 添加「网站回调域」: `${logto_endpoint}/callback/${connector_id}`
29+
3. 从应用信息页获取 `APP ID``APP Key`
30+
4. 将第 3 步获取的值填入 Logto 管理控制台的 `clientId``clientSecret` 字段
31+
32+
## 权限要求
33+
34+
使用此连接器需要在QQ互联平台申请以下权限:
35+
36+
1. **UnionID权限**:必须申请`UnionID`接口调用权限,这确保我们能获取用户的唯一标识。
37+
请通过[QQ互联平台](https://connect.qq.com/)申请此权限。
38+
39+
2. **默认scope**`get_user_info`
40+
用于获取用户的基本信息,如昵称、头像等。
41+
默认情况下,如果不设置scope参数,系统会使用此权限。
42+
43+
## 测试QQ连接器
44+
45+
大功告成!别忘了在[登录体验](https://{logto_endpoint}/console/connectors/social)中启用该连接器。
46+
47+
## 参考
48+
49+
- [QQ Connect 接入指南](https://wiki.connect.qq.com/%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C_oauth2-0)
50+
- [QQ开放平台API文档](https://wiki.connect.qq.com/)
Lines changed: 33 additions & 0 deletions
Loading
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "@logto/connector-qq",
3+
"version": "0.1.0",
4+
"description": "QQ web connector implementation.",
5+
"author": "Yen Harvey. <[email protected]>",
6+
"dependencies": {
7+
"@logto/connector-kit": "workspace:^4.3.0",
8+
"got": "^14.0.0",
9+
"@silverhand/essentials": "^2.9.1",
10+
"ky": "^1.2.3",
11+
"zod": "3.24.3"
12+
},
13+
"main": "./lib/index.js",
14+
"module": "./lib/index.js",
15+
"exports": "./lib/index.js",
16+
"license": "MPL-2.0",
17+
"type": "module",
18+
"files": [
19+
"lib",
20+
"docs",
21+
"logo.svg",
22+
"logo-dark.svg"
23+
],
24+
"scripts": {
25+
"precommit": "lint-staged",
26+
"check": "tsc --noEmit",
27+
"build": "tsup",
28+
"dev": "tsup --watch",
29+
"lint": "eslint --ext .ts src",
30+
"lint:report": "pnpm lint --format json --output-file report.json",
31+
"test": "vitest src",
32+
"test:ci": "pnpm run test --silent --coverage",
33+
"prepublishOnly": "pnpm build"
34+
},
35+
"engines": {
36+
"node": "^22.14.0"
37+
},
38+
"eslintConfig": {
39+
"extends": "@silverhand",
40+
"settings": {
41+
"import/core-modules": [
42+
"@silverhand/essentials",
43+
"got",
44+
"nock",
45+
"snakecase-keys",
46+
"zod"
47+
]
48+
}
49+
},
50+
"prettier": "@silverhand/eslint-config/.prettierrc",
51+
"publishConfig": {
52+
"access": "public"
53+
},
54+
"devDependencies": {
55+
"@silverhand/eslint-config": "6.0.1",
56+
"@silverhand/ts-config": "6.0.0",
57+
"@types/node": "^22.14.0",
58+
"@types/supertest": "^6.0.2",
59+
"@vitest/coverage-v8": "^3.1.1",
60+
"eslint": "^8.56.0",
61+
"lint-staged": "^15.0.2",
62+
"nock": "^14.0.3",
63+
"prettier": "^3.5.3",
64+
"supertest": "^7.0.0",
65+
"tsup": "^8.3.0",
66+
"typescript": "^5.5.3",
67+
"vitest": "^3.1.1"
68+
}
69+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import type { ConnectorMetadata } from '@logto/connector-kit';
2+
import { ConnectorPlatform, ConnectorConfigFormItemType } from '@logto/connector-kit';
3+
4+
/**
5+
* QQ Connector Constants
6+
* These are the key API endpoints and default scopes used in the QQ OAuth 2.0 authorization flow.
7+
* @see https://wiki.connect.qq.com/%e5%87%86%e5%a4%87%e5%b7%a5%e4%bd%9c_oauth2-0
8+
*/
9+
// Get Authorization Code https://wiki.connect.qq.com/%e4%bd%bf%e7%94%a8authorization_code%e8%8e%b7%e5%8f%96access_token
10+
export const authorizationEndpoint = 'https://graph.qq.com/oauth2.0/authorize';
11+
// Obtain Access Token via Authorization Code https://wiki.connect.qq.com/%e4%bd%bf%e7%94%a8authorization_code%e8%8e%b7%e5%8f%96access_token
12+
export const accessTokenEndpoint = 'https://graph.qq.com/oauth2.0/token';
13+
// Get User Information https://wiki.connect.qq.com/openapi%e8%b0%83%e7%94%a8%e8%af%b4%e6%98%8e_oauth2-0
14+
export const userInfoEndpoint = 'https://graph.qq.com/user/get_user_info';
15+
// Get User OpenID & UnionID (OAuth 2.0)
16+
// https://wiki.connect.qq.com/%e8%8e%b7%e5%8f%96%e7%94%a8%e6%88%b7openid_oauth2-0
17+
// https://wiki.connect.qq.com/unionid%e4%bb%8b%e7%bb%8d
18+
export const openIdEndpoint = 'https://graph.qq.com/oauth2.0/me';
19+
20+
// Default scopes for QQ OAuth 2.0
21+
export const defaultScope = 'get_user_info,get_unionId';
22+
23+
export const defaultMetadata: ConnectorMetadata = {
24+
id: 'qq-universal',
25+
target: 'qq',
26+
platform: ConnectorPlatform.Universal,
27+
name: {
28+
en: 'QQ',
29+
'zh-CN': 'QQ',
30+
},
31+
logo: './logo.svg',
32+
logoDark: './logo.svg',
33+
description: {
34+
en: 'QQ is a social platform by Tencent with over 600 million users.',
35+
'zh-CN': 'QQ是腾讯旗下拥有超过6亿用户的社交平台。',
36+
},
37+
readme: './README.md',
38+
formItems: [
39+
{
40+
key: 'clientId',
41+
type: ConnectorConfigFormItemType.Text,
42+
label: 'Client ID',
43+
required: true,
44+
placeholder: '<client-id>',
45+
},
46+
{
47+
key: 'clientSecret',
48+
type: ConnectorConfigFormItemType.Text,
49+
label: 'Client Secret',
50+
required: true,
51+
placeholder: '<client-secret>',
52+
},
53+
{
54+
key: 'scope',
55+
type: ConnectorConfigFormItemType.Text,
56+
label: 'Scope',
57+
required: false,
58+
placeholder: 'get_user_info,get_unionId',
59+
description: '逗号分隔的 scope 列表。如果不提供,默认为 "get_user_info,get_unionId"。',
60+
},
61+
],
62+
};
63+
64+
export const defaultTimeout = 5000;

0 commit comments

Comments
 (0)