接口描述
校验 client_id、client_secret,校验成功后返回授权令牌。
请求方法
POST
请求地址
/auth/oauth2/token
请求参数
参数 | 参数位置 | 类型 | 是否必填 | 描述 |
Authorization | Header | String | 是 | 接口鉴权值, Basic base64encode(<client_id>:(client_secret)) 。鉴权模式为 client_secret_basic 时,必须上送该参数 |
client_id | Query | String | 是 | |
grant_type | Query | String | 是 | 固定值“client_credentials” |
client_secret | Query | String | 是 | 客户端 Secret,可参见 应用管理页面 > 选定指定应用 > 单击应用配置 > 对应的“Client Secret”。含有特殊字符,需要做 URLEncode。鉴权模式为 client_secret_post 时,必须上送该参数 |
返回参数
参数 | 参数位置 | 类型 | 描述 |
access_token | Body | String | access_token |
id_token | Body | String | id_token |
expires_in | Body | Long | access_token有效时间,与创建应用时设置的“access_token有效期”一致 |
refresh_token | Body | String | 固定为空,该模式不提供 refresh_token |
输入示例
client_secret_post 鉴权模式
https://<auth_domain>/auth/oauth2/token?client_id=ODQyNGJlYmFjYWF****4YjkwNjU4MzMxOThkMGU&grant_type=client_credentials&client_secret=oG412Uk6EdbfXtgUW****1j%256
client_secret_basic 鉴权模式
Authorization: 'Basic WTJKbFlUUmhZVGszWV****bnZ1Qjh0SS9Jd1VFODFudw=='https://<auth_domain>/auth/oauth2/token?grant_type=client_credentials
返回示例
{"access_token": "c6a40b1****058eaed0f59509b541","expires_in": 7200,"refresh_token": "6865e92a****01df8081e4562e26c82"}
说明
client_credentials 模式不会返回 id_token。