mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-11-07 09:47:23 +00:00
feat(channels): MiniMax 渠道 —— PKCE 设备码流(RFC 8628)
第二个真实厂商,采用纯 HTTP 的设备码授权(无需本地服务器):
- 申请: POST account.minimax.cn/oauth2/device/code
body: client_id=mcode-public&scope=agent.default&audience=agent-backend
&code_challenge={S256(verifier)}&code_challenge_method=S256
- 轮询: POST account.minimax.cn/oauth2/token
body: grant_type=device_code&device_code=..&client_id=mcode-public
&code_verifier=..
- 签到: POST agent.minimax.cn/minimax-cloud/api/v1/signin/claim body {}
- 模型 fallback: MiniMax-M3.1-Flash-Preview / M3 / M2.7-highspeed
(对齐参考仓库 minimax-product.ts)
device-poll 流程的三步状态机在 start_login/poll_login 中实现:
begin 时生成 PKCE verifier/challenge 并申请设备码,把 verifier 存进
会话(只在换 token 时用一次,不回显),页面轮询 token 端点直到
authorization_pending 结束。
This commit is contained in:
@ -119,6 +119,36 @@ local PLATFORMS = {
|
||||
},
|
||||
},
|
||||
|
||||
-- MiniMax —— PKCE 设备码流(RFC 8628)。三步:申请码 → 用户授权 → 轮询换
|
||||
-- token。全程纯 HTTP,无需本地服务器;user_code 显示给用户输到授权页。
|
||||
{
|
||||
id = "minimax",
|
||||
name = "MiniMax",
|
||||
vendor = "minimax",
|
||||
flow = "device-poll",
|
||||
device = {
|
||||
-- 申请设备码:PKCE S256
|
||||
code_url = "https://account.minimax.cn/oauth2/device/code",
|
||||
code_body = "client_id=mcode-public&scope=agent.default&audience=agent-backend"
|
||||
.. "&code_challenge={challenge}&code_challenge_method=S256",
|
||||
-- 轮询换 token
|
||||
token_url = "https://account.minimax.cn/oauth2/token",
|
||||
token_body = "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code"
|
||||
.. "&device_code={device_code}&client_id=mcode-public&code_verifier={verifier}",
|
||||
interval = 5, -- 轮询间隔秒
|
||||
slow_down_guard = true, -- 响应 authorization_pending / slow_down 按标准处理
|
||||
},
|
||||
hosts = { "account.minimax.cn", "agent.minimax.cn" },
|
||||
base_url = "https://agent.minimax.cn",
|
||||
adapter = "openai",
|
||||
models = { "MiniMax-M3.1-Flash-Preview", "MiniMax-M3", "MiniMax-M2.7-highspeed" },
|
||||
-- 每日签到(两步:状态预检 + 领取;幂等靠服务端状态)
|
||||
checkin = {
|
||||
url = "https://agent.minimax.cn/minimax-cloud/api/v1/signin/claim",
|
||||
method = "POST", body = "{}",
|
||||
},
|
||||
},
|
||||
|
||||
-- 服务端浏览器兜底示范(回环重定向类)。真实厂商若需要可改 flow="vnc"。
|
||||
{
|
||||
id = "loopbackish",
|
||||
|
||||
Reference in New Issue
Block a user