POST/v1/oauth/token
Stable2026-04-01Try it

OAuthAuthorizationService.Token

获取 Token

用授权码、刷新 token 或客户端凭证换取 token 对。

Authentication

无需鉴权

该接口为公共接口,可直接调用;如携带 OAuth 2.0 access_token 或 API Key 也不会被拒绝。

Request body · TokenRequest

字段类型必填描述
grant_typeGrantType——
codestring—用于 authorization_code 授权
redirect_uristring——
code_verifierstring—PKCE verifier
refresh_tokenstring—用于 refresh_token 授权
client_idstring—客户端身份验证(所有授权类型)
client_secretstring——
scopestring—请求的 scope(可选,用于收窄)
noncestring—OIDC nonce (Core 1.0 §3.1.2.1)。可选。旧客户端兼容兜底:标准路径是在 /authorize 请求携带 nonce(平台持久化并在交换时自动回灌 id_token),无需在 token 请求重传。仅当授权码上没有已持久化的 nonce 时,平台才使用本字段的值。仅当 grant_type=authorization_code 且 scope 包含 "openid" 时有意义;其它情况会被忽略。

Response

200 OK · TokenResponse

字段类型必填描述
access_tokenstring——
token_typestring—"Bearer"
expires_ininteger (int32)——
refresh_tokenstring—client_credentials 授权不返回
scopestring—实际授予的 scope
id_tokenstring—OIDC ID Token (JWT, RS256)。仅当原始 /token 请求 scope 含 "openid" 时返回;否则为空串。 平台采用 access_token / id_token **严格分离**的双 token 模型: - access_token:opaque 字符串,资源 API 调用 Authorization: Bearer 使用,由平台网关通过 IntrospectToken 校验。 - id_token:JWT,用于客户端**本地**…

错误响应 · google.rpc.Status

非 2xx 响应均按 AIP-193 规范包装为google.rpc.Status,含 code /message /details 三段。details[].reason 是机器可读的具体错误原因码,可用于客户端分支处理。

字段类型必填描述
codeinteger (int32)—The status code, which should be an enum value of google.rpc.Code.
messagestring—A developer-facing error message.
detailsarray<Any>—A list of messages that carry the error details.

Examples

curl -X POST \
  'https://api.appforges.com/v1/oauth/token' \
  -H 'Authorization: Bearer $ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "grant_type": "GRANT_TYPE_UNSPECIFIED",
    "code": "string",
    "redirect_uri": "string",
    "code_verifier": "string",
    "refresh_token": "string",
    "client_id": "string",
    "client_secret": "string",
    "scope": "string",
    "nonce": "string"
  }'
OpenAPI spec v0.59.4 · synced 10/11/2026, 11:27:14 PM