Skip to content

获取自建应用的租户access_token

请求说明

请求地址{配置域名}/openapi/oauth2/token
请求方法POST
权限要求

请求头

Header名称参数类型是否必填说明
Content-Typestring使用:application/x-www-form-urlencoded

请求体(Body)

名称参数类型是否必填说明
grant_typestring授权类型,使用:client_credentials
client_idstring应用 APPID
client_secretstring在HTTPs环境下,可为明文应用 APPKEY;在非HTTPs环境下,为保证client_secret安全传输,需要进行加密处理,可参考《client_secret加密处理说明》

请求地址示例

json
[POST] {配置域名}/openapi/oauth2/token

请求体示例

json
// Content-Type: application/x-www-form-urlencoded
// 数据示例

grant_type=client_credentials&client_id=AK2024*********&client_secret=6*********

接口成功响应体

📌 请注意:
每个 access_token 的有效时长为 24 小时,若过期,重新获取的 access_token 的值与原 access_token不一致,请注意区分使用;
> 建议应用开发方维护保存好有效期内的access_token ,在调接口时优先使用已保存的,不推荐每次调接口都重新请求获取 access_token

名称参数类型说明
access_tokenstring授权 token
expires_ininteger授权 token 有效时长,单位:秒
token_typestringtoken 类型,一般为 Bearer

接口失败响应体

名称参数类型说明
codeinteger错误码。非 0 表示失败,参照《状态码说明》
msgstring错误信息

响应体示例

json
// Content-Type: application/json

{
  "access_token": "eyJhb******B7Re55MYSo",
  "expires_in": 86400,
  "token_type": "Bearer"
}