获取服务端token
POST/auth/v1/token/clientCredential
获取服务端token, 服务端token没有具体的用户身份, 自动授予管理员权限, 不支持刷新token。
- access_token有效期为432000秒, 客户端可按照有效期适当缓存, 不要频繁调用此接口生成token, 可能会被限频。
- 支持通过腾讯云SecretId/SecretKey获取, 需通过腾讯云控制台, 获取SecretId/SecretKey
- 支持通过腾讯云v3签名获取, 参考接口, 获取腾讯云v3签名
关键特性:
- 不返回refresh_token
- 自动授予超级管理员权限
安全规范:
- SecretKey需存储于安全介质
- 调用方需具备服务端可信环境
Request
Header Parameters
- 如果为secretId和secretKey, 值的格式为Basic ${base64(SecretId:SecretKey)}
- 如果使用腾讯云v3签名来生成token, 值为生成的腾讯云v3签名的值
Authorization stringrequired
Example: - Authorization: Basic c2VjcmV0OmNvbS1zaWduYXR1cmU=
- Authorization: TC3-HMAC-SHA256 xxx
- application/json
Body
grant_type string
授权类型, 固定为client_credentials
Responses
- 200
- 400
- 500
Response Headers
- application/json
- Schema
- Example (from schema)
- Example
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"
]
}
{
"token_type": "Bearer",
"access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjlkMWRjMzFlLWI0ZDAtNDQ4Yi1hNzZmLWIwY2M2M2Q4MTQ5OCJ9.eyJpc3MiOiJodHRwOi8vbG93Y29kZS01ZzlhYzIwdTJhMjdkYTQ2LmFwLXNoYW5naGFpLnRjYi1hcGkudGVuY2VudGNsb3VkYXBpLmNvbSIsInN1YiI6IjE4NDk3NTUxMTk4NDA0OTc2NjQiLCJhdWQiOiJsb3djb2RlLTVnOWFjMjB1MmEyN2RhNDYiLCJleHAiOjE3MzQ2NzU4ODksImlhdCI6MTczNDY2ODY4OSwiYXRfaGFzaCI6InIudjVEQk10MjJSRWVHeGZ0a3VOVTFOZyIsInNjb3BlIjoidXNlciBzc28iLCJwcm9qZWN0X2lkIjoibG93Y29kZS01ZzlhYzIwdTJhMjdkYTQ2IiwicHJvdmlkZXJfdHlwZSI6ImVtYWlsIiwibWV0YSI6eyJ3eE9wZW5JZCI6IiIsInd4VW5pb25JZCI6IiJ9LCJ1c2VyX3R5cGUiOiIifQ.hOKXMtMmtbeyZSlnlprXIGVtKpBw8t7Syq45sqMX3oC2TqZ4Gl4AieQCyQF6KMLh4BH3PHt_eoJxJGQYJXx-bXalP_S94A22KpiB0n5tVb8MAV_8YbTT0oNgQeQMkGgfMMfEECle82daASgxEIHUO0UyhY0mC3O3FoGpO6rrOXVL_mOCd3Ij80dMy59XjEJn3wmnnIS3bMLAIM2GodUYT9s9C1z_p6JPWlCbxlTxst6q_lHGwvpcO8UxWvra8zQbfStn0Kej3anEYfnuWYcgLAfkAPv3eeWHii0_nLTC300Kwnhk4RCFQ7U89XHoJ4O773DeA9c4ZFdXjHicysBDUQ",
"expires_in": 432000
}
参数错误
- application/json
- Schema
- Example (from schema)
- Example
Schema
error 错误信息 (string)
error_code int32
error_description 错误描述 (string)
{
"error": "string",
"error_code": 0,
"error_description": "string"
}
{
"error": "invalid_argument",
"error_code": 3,
"error_description": "can not find secretId and secretKey from header"
}
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...