access_token是全局唯一API接口调用凭据,调用各接口时都需使用access_token。开发者需要进行妥善保存。access_token的存储至少要保留512个字符空间。access_token的有效期目前为2个小时,需定时重新获取或刷新。
access_token的使用及生成方式说明:
access_token的有效期通过返回的expires_in来传达,目前是7200秒之内的值。建议开发者使用中控服务器统一获取和刷新access_token,其他业务逻辑服务器所使用的access_token均来自于该中控服务器,不应该各自去刷新,否则容易造成冲突,导致access_token覆盖而影响业务.
接口调用请求说明
https请求方式: POST https://www.idcd.com/oauth/token
参数说明
参数 | 类型 | 是否必须 | 说明 |
---|---|---|---|
grant_type | string | M | 获取access_token填写client_credential |
client_id | string | M | 客户端ID |
client_secret | string | M | 客户端密钥 |
请求参数
{
"grant_type": "client_credentials",
"client_id": "9b8bf2d0-245b-4c6c-bde8-5c4e33ed7cea",
"client_secret": "g8hpelnQAxfiuuJFc4dTaHI4M5dxSRXaOfphyMtb",
"scope": ""
}
返回参数
{
"token_type": "Bearer",
"expires_in": 7200,
"access_token": "ACCESS TOKEN"
}
请求示例
curl --location --request POST 'https://www.idcd.com/oauth/token' \
--header 'Content-Type: application/json' \
--data-raw '{
"grant_type": "client_credentials",
"client_id": "9b8bf2d0-245b-4c6c-bde8-5c4e33ed7cea",
"client_secret": "g8hpelnQAxfiuuJFc4dTaHI4M5dxSRXaOfphyMtb"
}'