跳到主要内容

获取用户 Token

使用授权码换取用户级访问令牌。

接口信息​

属性值
请求方式POST
请求路径/v1/auth/user-token
鉴权方式无需鉴权

请求参数​

参数类型必填说明
app_idstring是应用 ID
app_secretstring是应用密钥
codestring是授权码
grant_typestring是固定值 authorization_code

请求示例​

curl -X POST 'https://api.im.example.com/v1/auth/user-token' \
-H 'Content-Type: application/json' \
-d '{
"app_id": "cli_xxxxxx",
"app_secret": "xxxxxx",
"code": "abc123",
"grant_type": "authorization_code"
}'

响应参数​

参数类型说明
access_tokenstring用户访问令牌
refresh_tokenstring刷新令牌
expires_innumber有效期(秒)
user_idstring用户 ID

响应示例​

{
"code": 0,
"msg": "success",
"data": {
"access_token": "u-xxxxxx",
"refresh_token": "r-xxxxxx",
"expires_in": 7200,
"user_id": "user_001"
}
}

错误码​

错误码说明
10201code 无效或已过期
10202code 已被使用
10203grant_type 错误