fix(kook): KOOK 机器人鉴权用 Authorization: Bot <token> 而非 Bearer
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

httpclient 硬编码 Bearer,导致 KOOK bot token 被当 OAuth2 用户令牌发,
/ gateway/index 返回 401『登录环境异常』。按 KOOK reference 鉴权规范,
给共享 httpclient 增加可配置 authScheme(默认 Bearer),KOOK 用 Bot。

- httpclient: 新增 WithAuthScheme 选项 + authScheme 字段,do() 按 scheme 组装
- kook/adapter: 装配时传 WithAuthScheme("Bot")
- 同步修正 config.go 注释与 send/identity 测试断言
This commit is contained in:
Aska committed 2026-09-07 16:59:53 +08:00
1 parent e9df928072
commit c1bd740f7c
5 files changed
+36 -18

No files matched your search

+4
View File
@@ -105,9 +105,13 @@ func New(cfg Config, opts ...Option) *Adapter {
a.baseURL = defaultBaseURL
}
}
// KOOK authenticates bots with `Authorization: Bot <token>` (not "Bearer",
// which is reserved for OAuth2 user tokens). This is mandated by the KOOK
// reference: /doc/reference §鉴权.
a.http = httpclient.New(
httpclient.WithBaseURL(a.baseURL),
httpclient.WithToken(cfg.BotToken),
httpclient.WithAuthScheme("Bot"),
httpclient.WithHTTPClient(a.client),
httpclient.WithLogger(a.log),
)