授权码流程第 1 步:前端授权页携带用户 JWT 调用本接口,校验 client_id / redirect_uri / scope / PKCE 后返回应用信息与规范化后的 scope 供用户确认;不会直接 302 跳转。redirect_uri 必须与应用登记的某个地址完全一致;回环地址(127.0.0.1/localhost/::1)按 RFC 8252 忽略端口匹配,但 scheme/host/path/query 必须一致。可用 scope(空格分隔):user:read(用户信息读取)、session:read(会话信息读取)、tunnel:read(隧道信息读取)、tunnel:write(隧道管理)、traffic:read(流量统计读取)、domain:read(域名信息读取)、domain:write(域名管理)、node:read(节点信息读取)、all(完全访问,展开为除 all 外的全部 8 个 scope);另支持通配符 user:* / session:* / tunnel:* / traffic:* / domain:* / node:*。无效 scope 会被静默忽略;scope 为空时默认 user:read tunnel:read traffic:read;全部无效时默认 user:read tunnel:read traffic:read domain:read。不再支持 tunnel 这类无冒号简写。PKCE:code_challenge_method 支持 plain / S256(仅传 code_challenge 不传 method 时视为 plain);plain 时 code_challenge 须匹配 ^[A-Za-z0-9-._~]{43,128}$,S256 时须为 43 位 base64url。public 客户端必须携带 code_challenge。
鉴权:需要用户 JWT(Authorization: Bearer )
OAuth2:不允许使用 OAuth2 Access Token 调用
错误响应:
| code | msg |
|---|---|
| 401 | authorization header is missing |
| 401 | authorization header format must be Bearer {token} |
| 401 | invalid token |
| 401 | token has been revoked |
| 503 | token validation temporarily unavailable |
| 403 | 此接口不支持OAuth2访问 |
| 400 | 请求参数错误: <校验错误详情> |
| 400 | 无效的客户端ID |
| 400 | 应用已停用 |
| 400 | 无效的重定向URI |
| 400 | 无效的权限范围 |
| 400 | 缺少 code_challenge 参数 |
| 400 | public 客户端必须使用 PKCE |
| 400 | 不支持的 code_challenge_method,仅支持 plain 或 S256 |
| 400 | code_challenge 格式不正确 |
| 500 | 内部错误 |