1 IoT平台后台登录API约定
1.1 帐号来源
帐号来自开放平台的开发者帐号。
1.2 接口请求约定
除白名单接口外,所有经过IoT后台网关的请求需在头部携带token标识。
HTTP头部标识名称: iotAccountToken
HTTP头部标识值: 由《2.1 登录接口》或 《2.2 刷新授权凭证接口》接口获取的access_token
1.3 API 安全规范
IoT后台网关使用JWT认证,任何调用IoT平台后台管理的API,须按《1.2 接口请求约定》在http头部携带token标识。token未携带或不正确都会被网关层拒绝。
1.4 IoT平台后台帐号接口响应约定
1.4.1 响应格式
正确响应:
{
"code": "200",
"message":"success",
"data": {
"result":[{...},{..}]
}
}
错误响应:
{
"code": "非200",
"message":"错误提示"
}
1.4.2 错误码
code | message | 说明 |
---|---|---|
4031021 | token过期 | |
4031023 | 刷新token过期 | |
其他非200 | 通用错误码 | |
401 | 无权访问 |
2 文档
2.1 登录接口
请求信息
HTTP协议:HTTP,HTTPS
uri:/v1/user/iot/access_token
方法:POST
请求Body
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
user_name | string | y | 开发者帐号 |
pwd | String | y | 密码, 明文须加密,见:http://arch.smartmideazy.com/docs/account/account-doc.html 《5.2 密码明文加密》部分 |
client_id | String | y | 由睿智云中台分配的客户端标识; 见:《4 SIT环境 client_id 及client_secret》 |
client_secret | String | y | 由睿智云中台分配的客户端密钥 |
请求Body描述(非Form表单数据)
{"user_name": "betty", "pwd": "GuXq7XwbRMDWFMz63tSsZG0LqMi6R1+qW3B6Rg7zblWdIOAOIl8LdDygVSP/5kohYrY/7kCKp5TVKRwsZal+YfGboWaK96CR/Y8yKUHWIBrglj+ujQc3ibd2QBE8N/yBHM6cFKrKWZMpbV1D8yG5OSUt81SFdCu88ENGxT5tDa4=", "client_id":XX, "client_sectet":XXX}
正确返回:
{
"code": "200",
"data": {
"access_token": "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJwbGF0Zm9ybV90aWNrZXQiLCJqdGkiOiIzMTI1Yzg3Ny0wZDdkLTRiY2EtOWM4Yy1kYTRmNzE4ZGNjMGEiLCJ1c2VyX25hbWUiOiJpb3RfZGV2ZWxvcGVyIiwibW9iaWxlIjoiMTMwMDAwMDAwMDAiLCJpZCI6MTEsImNsaWVudF9pZCI6ImlvdC1jbGllbnQiLCJpc3MiOiJyZW1hYyIsImlhdCI6MTY1NzY5MTE3NCwiZXhwIjoxNjU3Njk4Mzc0fQ.VAFc0l0YUcNYJaEx24SmuIqh1vDpY0YAFfed1-fLcHEpDW80hA9yvutvzk6kbkJLUFX0fifZ1-MftMXZA1vsnfsfl1sEKUldIFZNb-bIHgDGwPpcThPn0K2Z9q2BTpzgnYbILIu1b6ZwXGb2jsHhwlrfs_jJqYZ1ibqVzflQY_Q",
"token_type": "bearer",
"refresh_token": "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJwbGF0Zm9ybV90aWNrZXQiLCJqdGkiOiIzMTI1Yzg3Ny0wZDdkLTRiY2EtOWM4Yy1kYTRmNzE4ZGNjMGEiLCJ1c2VyX25hbWUiOiJpb3RfZGV2ZWxvcGVyIiwiYXRpIjoiMzEyNWM4NzctMGQ3ZC00YmNhLTljOGMtZGE0ZjcxOGRjYzBhIiwibW9iaWxlIjoiMTMwMDAwMDAwMDAiLCJpZCI6MTEsImNsaWVudF9pZCI6ImlvdC1jbGllbnQiLCJpc3MiOiJyZW1hYyIsImlhdCI6MTY1NzY5MTE3NCwiZXhwIjoxNjU3NzI3MTc0fQ.ZIs18V7CvS2nWRE5VG86Irkn9AGWbvF7gsOr4Pwf5s8VKnQcL1ZEPCd0prFKFla97gjxMYt9rBAnLqoC9a3XMj6BdTVPkwKbbOmDXBNxOlmzjB5WVdSQ3C9St_ck-W9kRGNXt17sth7becVxLDZVKk9Cwc7sjAWIuYrsD6BUdeI",
"scope": "all",
"jti": "3125c877-0d7d-4bca-9c8c-da4f718dcc0a",
"expires_in": 7200
},
"message": "成功"
}
返回属性说明
字段 | 类型 | 说明 |
---|---|---|
access_token | String | 睿智云平台授权凭证,过期时间2小时,第三方平台访问睿智云API的唯一 凭证。过期时,请拿refresh_token获取新的凭证。 |
refresh_token | String | 睿智云平台授权刷新凭证,过期时间10小时,当access_token过期时,可以通过refresh_token获取新的凭证 |
expires_in | Int | 从当前返回结果的时间开始,access_token有效存活的时间,单位为秒 |
2.2 刷新授权凭证接口
协议:HTTP
URL: /v1/user/iot/refresh_token
方法: POST
请求示例:
{"client_id": "睿智云中台分配CLIENT_ID", "client_secret":"睿智云中台分配CLIENT_SECRET", "grant_type":"refresh_token", "refresh_token":"eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJwbGF0Zm9ybV90aWNrZXQiLCJqdGkiOiIwZDg2NjRjYy02NzExLTQ1NmQtOWYyOC1iZGNkM2M0MzNhMzgiLCJ1c2VyX25hbWUiOiJndnNzb3VuZCIsImF0aSI6IjBkODY2NGNjLTY3MTEtNDU2ZC05ZjI4LWJkY2QzYzQzM2EzOCIsIm5hbWUiOiJndnNzb3VuZCIsImlzcyI6InJlbWFjIiwiaWF0IjoxNjU0MDQ1OTQ5LCJleHAiOjE2NTQwODE5NDl9.qcZxyAQdB6m-qUcKawOrgTiye8bWDmYP3Dsfw0piX2MlaS9JtPwDaVCtv8Xg1GBRHzrqW7rl1CMICKW7TPdzQqTKN0kQtHhMaNlalZrulsR69GB4NqSPUgDGNoYrEVqcMuet5F0PnioSW8-6U0CxO5cBS_5EeAFQJpmo5hbESJU"}
请求属性
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
client_id | String | y | 由睿智云中台分配的客户端标识 |
client_secret | String | y | 由睿智云中台分配的客户端密钥 |
refresh_token | String | y | 最近一次登录获取的refresh_tokn |
正确返回:
{
"code": "200",
"data": {
"access_token": "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJwbGF0Zm9ybV90aWNrZXQiLCJqdGkiOiIzMTI1Yzg3Ny0wZDdkLTRiY2EtOWM4Yy1kYTRmNzE4ZGNjMGEiLCJ1c2VyX25hbWUiOiJpb3RfZGV2ZWxvcGVyIiwibW9iaWxlIjoiMTMwMDAwMDAwMDAiLCJpZCI6MTEsImNsaWVudF9pZCI6ImlvdC1jbGllbnQiLCJpc3MiOiJyZW1hYyIsImlhdCI6MTY1NzY5MTE3NCwiZXhwIjoxNjU3Njk4Mzc0fQ.VAFc0l0YUcNYJaEx24SmuIqh1vDpY0YAFfed1-fLcHEpDW80hA9yvutvzk6kbkJLUFX0fifZ1-MftMXZA1vsnfsfl1sEKUldIFZNb-bIHgDGwPpcThPn0K2Z9q2BTpzgnYbILIu1b6ZwXGb2jsHhwlrfs_jJqYZ1ibqVzflQY_Q",
"token_type": "bearer",
"refresh_token": "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJwbGF0Zm9ybV90aWNrZXQiLCJqdGkiOiIzMTI1Yzg3Ny0wZDdkLTRiY2EtOWM4Yy1kYTRmNzE4ZGNjMGEiLCJ1c2VyX25hbWUiOiJpb3RfZGV2ZWxvcGVyIiwiYXRpIjoiMzEyNWM4NzctMGQ3ZC00YmNhLTljOGMtZGE0ZjcxOGRjYzBhIiwibW9iaWxlIjoiMTMwMDAwMDAwMDAiLCJpZCI6MTEsImNsaWVudF9pZCI6ImlvdC1jbGllbnQiLCJpc3MiOiJyZW1hYyIsImlhdCI6MTY1NzY5MTE3NCwiZXhwIjoxNjU3NzI3MTc0fQ.ZIs18V7CvS2nWRE5VG86Irkn9AGWbvF7gsOr4Pwf5s8VKnQcL1ZEPCd0prFKFla97gjxMYt9rBAnLqoC9a3XMj6BdTVPkwKbbOmDXBNxOlmzjB5WVdSQ3C9St_ck-W9kRGNXt17sth7becVxLDZVKk9Cwc7sjAWIuYrsD6BUdeI",
"scope": "all",
"jti": "3125c877-0d7d-4bca-9c8c-da4f718dcc0a",
"expires_in": 7200
},
"message": "成功"
}
3 域名
SIT环境: https://api-sit.remacsmart.com
生产环境 : https://api-sit.remacsmart.com
4 SIT环境 client_id 及client_secret
client_id | client_sectet | 环境 |
---|---|---|
iot-client | TKFivtoavjXyecMPDVr9S/z8nZl6dL/Ye86yTu77JiLbFDpa4z48GrI04VJ+zg/DVnxsDlQ3txVcBCuONvQUsJpEukBoAPxawXxQ9NFGNAjxIIQBf4DOf0UxzXFDm29iEWObS7GDWlME3zNVkzAx6ubq8axJN2io7q7WnVrLBBI= | SIT |
5 密码明文加密公钥
具体加密明文部分见: http://arch.smartmideazy.com/docs/account/account-doc.html
《3.1 用于密码明文加密的公钥 (已去掉首部 -----BEGIN PUBLIC KEY-----和 尾部-----END PUBLIC KEY-----)》章节。
测试环境:
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRx94bsVgoza8UD97XeXZM3/cu
sKZqdbmoHSYHp0fg/LObJnMYIzDri+fJ2ZBE/BqIAgou2EQWJG3yu9C44WEbJnbn
ntR1LfeVrp6e/5ZsWhjjgyikCfaysEJHSz7cNGdpcx7tgSzGGvUInK8F4lVaHyb8
et1AVnr567ArJg6CoQIDAQAB