OAuthAuthorizationService.Token
获取 Token
用授权码、刷新 token 或客户端凭证换取 token 对。
Authentication
无需鉴权
该接口为公共接口,可直接调用;如携带 OAuth 2.0 access_token 或 API Key 也不会被拒绝。
Request body · TokenRequest
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
grant_type | GrantType | — | — |
code | string | — | 用于 authorization_code 授权 |
redirect_uri | string | — | — |
code_verifier | string | — | PKCE verifier |
refresh_token | string | — | 用于 refresh_token 授权 |
client_id | string | — | 客户端身份验证(所有授权类型) |
client_secret | string | — | — |
scope | string | — | 请求的 scope(可选,用于收窄) |
nonce | string | — | 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_token | string | — | — |
token_type | string | — | "Bearer" |
expires_in | integer (int32) | — | — |
refresh_token | string | — | client_credentials 授权不返回 |
scope | string | — | 实际授予的 scope |
id_token | string | — | 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 是机器可读的具体错误原因码,可用于客户端分支处理。
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
code | integer (int32) | — | The status code, which should be an enum value of google.rpc.Code. |
message | string | — | A developer-facing error message. |
details | array<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