刷新token
接口说明
应用服务器通过鉴权接口获取到的accessToken是有效时间的,在accessToken快过期时,应用服务器通过调用此接口,获取新的accessToken。
URI
| 请求方法 | POST |
|---|---|
| URI | /iocm/app/sec/v1.1.0/refreshToken |
| 传输协议 | HTTPS |
请求参数
| 参数 | 必选/可选 | 类型 | 位置 | 描述 |
|---|---|---|---|---|
| appId | 必选 | String(256) | body | 访问物联网平台的应用ID,在物联网平台创建应用时由平台分配获得。 |
| secret | 必选 | String(256) | body | 访问物联网平台的应用密钥,与appId对应,在物联网平台创建应用时由平台分配获得。 |
| refreshToken | 必选 | String(256) | body | 刷新token,用来获取一个新的accessToken。refreshToken在调用鉴权接口或刷新token接口时获得。 |
响应参数
Status Code: 200 OK
| 参数 | 类型 | 描述 |
|---|---|---|
| scope | String(256) | 申请的权限范围,参数值固定为default。 |
| tokenType | String(256) | 鉴权token的类型,参数值固定为Bearer 。 |
| expiresIn | Integer(256) | accessToken的有效时间,参数值固定为3600秒。 |
| accessToken | String(256) | 鉴权参数,访问物联网平台API接口的凭证。 |
| refreshToken | String(256) | 鉴权参数,有效时间为24小时,用于“刷新Token”接口。当accessToken即将过期时,可通过“刷新Token”接口来获取新的accessToken。 |
请求示例
POST https://{host}:{port}/iocm/app/sec/v1.1.0/refreshToken
Content-Type: application/json
{
"appId": "******",
"secret": "******",
"refreshToken": "******"
} 响应样例
Status Code: 200 OK
Content-Type: application/json
{
"accessToken": "*******",
"tokenType": "*******",
"expiresIn": "*******",
"refreshToken": "*******",
"scope": "*******"
} 错误码
| Http状态码 | 错误码 | 错误描述 | 说明 |
|---|---|---|---|
| 400 | 100247 | Operation not allowed. The application has been frozen. | 应用冻结。 处理建议:请检查应用是否因为欠费冻结。 |
| 400 | 102202 | Required Parameter is null or empty. | 必选参数为空。 处理建议:请检查请求参数中的必选参数是否已填写。 |
| 400 | 50400 | The input is invalid. | 输入参数无效。 处理建议:请检查接口调用请求中携带参数的合法性。 |
| 401 | 100208 | AppId or secret is not right. | appId、secret或refreshToken错误。 处理建议:
|
| 500 | 50252 | Internal server error. | 服务器运行内部错误。 处理建议:物联网平台内部错误,请联系物联网平台维护人员处理。 |
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.