跳到主要内容

OAuth2.0授权

标准的OAuth2.0授权流程接口。

请求方式​

POST /api/v1/grant/oauth

请求参数​

参数名类型必填说明
grant_typestring是授权类型(authorization_code,refresh_token)
client_idstring是客户端ID
client_secretstring是客户端密钥
codestring否授权码(grant_type=authorization_code时必填)
refresh_tokenstring否刷新令牌(grant_type=refresh_token时必填)
redirect_uristring否回调地址(与注册时一致)

响应参数​

参数名类型说明
access_tokenstring访问令牌
token_typestring令牌类型(Bearer)
expires_inint过期时间(秒)
refresh_tokenstring刷新令牌
scopestring权限范围

请求示例​

{
"grant_type": "authorization_code",
"client_id": "client123",
"client_secret": "secret123",
"code": "authcode123",
"redirect_uri": "https://example.com/callback"
}

响应示例​

{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "refresh123456",
"scope": "read write"
}

错误码​

错误码说明
400参数错误
401认证失败
403客户端被禁用
500服务器内部错误

相关链接​