j9九游会登录/ 云商店/ / / / / / oauth获取accesstoken
更新时间:2024-04-26 gmt 08:00

oauth获取accesstoken-j9九游会登录

用于web端oauth登录认证场景,用户登录获得临时凭证后,saas服务器用临时凭证换取用户会话token。

uri

post /api/v1/oauth2/token

请求参数

表1 formurlencoded参数

参数

是否必选

参数类型

描述

client_id

string

应用标识,注册应用后,分配的clientid。

client_secret

string

应用密钥,注册应用后,分配的clientsecret。(解密后的明文)

code

string

授权码,认证登录后回调获取的授权码。(code值仅可使用一次)

grant_type

string

授权类型,固定值:authorization_code。

redirect_uri

string

回调地址,注册应用时填写的回调地址。

请求示例

post {domain_name}/api/v1/oauth2/token 
content-type: application/x-www-form-urlencoded 
code=z2d...& 
client_id=nzzewuija91dpsrdzqchmazih13aw...& 
client_secret=******...& 
redirect_uri=https://example.com& 
grant_type=authorization_code

响应参数

表2 响应body参数

参数

参数类型

描述

access_token

string

授权服务器返回给第三方应用的访问令牌。

token_type

string

访问令牌类型。固定值:bearer。

expires_in

long

访问令牌的有效期,以秒为单位。

scope

refresh_token

string

string

授权范围。

refresh_token string 刷新令牌,默认生成,有效期30天。

error

string

错误类型。

error_description

string

错误描述。

refresh_token有效期设置应比access_token长。

响应示例

表3 状态码

状态码

描述

200

请求成功。

400

请求错误。

状态码:200

请求成功。

示例1

{ 
"access_token" : "******", 
"token_type" : "bearer", 
"expires_in" : 7200, 
"scope" : "get_user_info" 
}

示例2

{ 
"access_token" : "******", 
"token_type" : "bearer", 
"expires_in" : 7200, 
"scope" : "get_user_info", 
"refresh_token" : "******" 
}

状态码:400

请求错误。

{ 
"error" : "invalid_grant", 
"error_description" : "invalid authorization code" 
}

相关文档

网站地图