POST /oauth/token

OAuth 2.0 令牌端点。支持 authorization_code、refresh_token、client_credentials、urn:ietf:params:oauth:grant-type:device_code 四种授权类型。支持 client_secret_basic(Authorization: Basic 头,RFC 6749 §2.3.1)、client_secret_post 与 private_key_jwt 客户端认证及 DPoP。返回扁平 JSON(无 code/message 信封)。参考:RFC 6749 §4.1.3 (Authorization Code Grant)、§4.3 (Resource Owner Password)、§4.4 (Client Credentials)、RFC 6749 §5.1-5.2、RFC 7636 (PKCE)、RFC 8628 §3.4 (Device Code)。

OAuth None application/x-www-form-urlencoded

请求参数

名称位置类型必填默认值示例约束描述
grant_type formData string 是 授权类型(authorization_code/refresh_token/client_credentials/urn:ietf:params:oauth:grant-type:device_code)
code formData string 否 授权码(authorization_code 时必填)
redirect_uri formData string 否 重定向URI(authorization_code 时必填)
client_id formData string 否 客户端ID
client_secret formData string 否 客户端密钥
refresh_token formData string 否 刷新令牌(refresh_token 时必填)
code_verifier formData string 否 PKCE Code Verifier(public client 时必填)
device_code formData string 否 设备码(device_code 时必填)
client_assertion_type formData string 否 客户端断言类型(private_key_jwt)
client_assertion formData string 否 客户端断言 JWT(private_key_jwt)

响应

状态描述Schema
200令牌响应(含 access_token, refresh_token, id_token 等)service-oauth/internal/handler/dto.OAuthTokenResponse
400unsupported_grant_type:不支持的授权类型。参考:RFC 6749 §5.2。service-oauth/internal/handler/dto.OAuthErrorResponse
401invalid_client:客户端认证失败。参考:RFC 6749 §5.2。service-oauth/internal/handler/dto.OAuthErrorResponse
429rate_limit_exceeded:请求频率过高,请稍后重试service-oauth/internal/handler/dto.OAuthErrorResponse
500server_error:授权服务器内部错误。参考:RFC 6749 §5.2。service-oauth/internal/handler/dto.OAuthErrorResponse

引用的 Schema

service-oauth/internal/handler/dto.AuthorizationDetailDTO

字段类型必填示例约束描述
actions array of

string

否 ['["list_accounts"', '"read_balances"]'] 操作
constraints object 否 扩展约束
data_types array of

string

否 ['["account_details"', '"balances"]'] 数据类型
identifier string 否 account-12345 标识符
locations array of

string

否 ['["https://example.com/accounts"]'] 位置
type string 否 account_information 授权类型

service-oauth/internal/handler/dto.OAuthErrorResponse

OAuth标准错误响应

字段类型必填示例约束描述
error string 否 invalid_request 错误码
error_description string 否 Missing required parameter 错误描述
error_uri string 否 https://docs.example.com/errors 错误URI
i18n_key string 否 error.oauth_invalid_request I18nKey 本地化键(AUTH-46①/U416):协议字段 error/error_description 保持 RFC 6749 §5.2 原样, 本字段是**附加**信息(omitempty;未知错误码不填),供前端/AI 客户端按键确定性渲染文案, 无需解析英文原文。仅出现在 JSON 错误体,不写入 302 错误重定向的查询串。
state string 否 state-123 状态

service-oauth/internal/handler/dto.OAuthTokenResponse

OAuth令牌响应

字段类型必填示例约束描述
access_token string 否 eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... 访问令牌
authorization_details array of

参见 service-oauth/internal/handler/dto.AuthorizationDetailDTO

否 RAR授权详情
dpop_access_token_bound boolean 否 访问令牌DPoP绑定确认(RFC 9449)
dpop_signing_alg string 否 DPoP签名算法(RFC 9449)
expires_in integer 否 3600 过期秒数
id_token string 否 eyJhbGci... OIDC ID令牌
refresh_token string 否 rt_abc123 刷新令牌
scope string 否 openid profile email 范围
token_type string 否 Bearer 令牌类型