获取或刷新token
POST/auth/v1/token
1.Refresh Token 刷新机制
接口说明
通过有效的refresh_token获取新的access_token,原refresh_token随即失效(符合RFC 6749 Section 6)
请求示例:
{
"client_id": "mock_AAU5Pw78ioGQnUP4",
"grant_type": "refresh_token",
"refresh_token": "mock_m.yPxK8mLnVrQwEoDzFcHbNtGsYvXpRjWq-3eSd2fA1gU5iI9kO0lP7uJ4mT6nB8yC_1xZ2vD3aQ4wF5eR6tG7hY8jM9kL0oN1iP2uK3lQ4mW5nX6bV7cC8dA9fS0gH1jJ2kL3mN4o"
}
2.密码模式认证
接口说明
基于Resource Owner Password Credentials Grant(RFC 6749 Section 4.3)获取access_token
请求示例:
{
"client_id": "mock_AAU5Pw78ioGQnUP4",
"grant_type": "password",
"username": "mock_user001",
"password": "mock_password@123"
}
3.客户端凭证模式
接口说明
采用Client Credentials Grant(RFC 6749 Section 4.4)获取服务端access_token
认证方式
请求头添加:
Authorization: Basic ${base64(SecretId:SecretKey)}
{
"client_id": "mock_AAU5Pw78ioGQnUP4",
"grant_type": "client_credentials"
}
关键特性:
- 不返回refresh_token
- 自动授予超级管理员权限
- 需通过腾讯云cam获取SecretId/SecretKey
安全规范:
- SecretKey需存储于安全介质
- 调用方需具备服务端可信环境
Request
Query Parameters
client_id string
应用对应的客户端id,默认为环境id,可以不传
Header Parameters
x-device-id stringrequired
设备id
- application/json
Body
grant_type 获取token的授权方式 (string)nullable
code grant_type 为 authorization_code 时使用 (string)
refresh_token refresh_token 刷新token时, 使用 (string)
username grant_type 为 password时使用 (string)
password grant_type 为 password时使用 (string)
scope scope,可选 (string)
nonce 随机字符串, 可选 (string)
code_verifier PKCE: code_verifier (string)
device_code Device Code Flow https://tools.ietf.org/html/rfc8628 (string)
Responses
- 200
- 500
A successful response.
Response Headers
- application/json
- Schema
- Example (from schema)
Schema
token_type 访问令牌类型 (string)
统一返回 Bearer
access_token 用户的访问令牌 (string)
用于访问云开发HTTP API的令牌,长度4096位以内
refresh_token 用户的刷新令牌 (string)
access_token过期可通过refresh_token刷新获取新的access_token,过期时间默认为31天。长度128位以内
expires_in int32
access_token的过期时间,单位为秒
scope 授权范围 (string)
sub 用户的唯一id (string)
groups string[]
{
"token_type": "string",
"access_token": "string",
"refresh_token": "string",
"expires_in": 0,
"scope": "string",
"sub": "string",
"groups": [
"string"
]
}
An unexpected error response.
Response Headers
- application/json
- Schema
- Example (from schema)
Schema
error 错误信息 (string)
error_code int32
error_description 错误描述 (string)
{
"error": "string",
"error_code": 0,
"error_description": "string"
}
Loading...