说明文档
切换说明
推送目标服务配置说明
云开发--消息转发配置--推送目标配置
- 配置说明
字段 | 值描述 |
---|---|
消息推送地址 | 需要您搭建的服务的外网地址 |
状态 | 应用:启用消息推送处理,不应用:不进行消息推送处理 |
类型 | 直接token模式、oauth2.0的credentials模式、oauth2.0的password模式 |
- 直接token模式
直接通过固定的token发送推送请求
字段 | 值描述 |
---|---|
请求Token | 请求您服务时的token,该token会设置到header的Authorization中 |
- 消息推送的请求示例:
Request Headers
Content-Type: application/json; charset=UTF-8 Authorization: token
Request Body
Request Body即消息推送内容,说明查看:可推送的消息内容
{ "id": "xxx", "type": "device_offline", "appid": "xxx", "payload": { "deviceSn": "xxx", "parentDeviceSn": null, "offline": 0 }, "timestamp": 1610431327806 }
Response Body
推送成功后,您需要返回的数据内容
{ "status": 0, //0:成功,非0:失败 "description": "成功" //响应描述 }
- oauth2.0的client credentials模式
token通过oauth2.0的client credentials模式下获取后,再发送推送请求
字段 | 值描述 |
---|---|
Token地址 | 支持oauth2.0的credentials模式的授权服务地址 |
Token有效时限(秒) | 从授权服务获取到的token的有效时限 |
OauthClient | oauth2.0的client_id |
OauthSecret | oauth2.0的secret |
OauthScope | oauth2.0的scope |
- client credentials模式下获取token的请求示例:
Request Headers
Content-Type: application/x-www-form-urlencoded Authorization: "Authorization","Basic " + base64Encode(client_id:secret)
Request Body
grant_type=client_credentials&scope=xxx
Response Body
授权成功后,您需要返回的数据内容
{ "access_token": "xxx", //消息推送请求时使用的token "token_type": "bearer", //token的类型 "expires_in": 86399, "scope": "xxx" }
- 消息推送的请求示例:
Request Headers
Content-Type: application/json; charset=UTF-8 Authorization: "bearer " + access_token
Request Body
Request Body即消息推送内容,说明查看:可推送的消息内容
{ "id": "xxx", "type": "device_offline", "appid": "xxx", "payload": { "deviceSn": "xxx", "parentDeviceSn": null, "offline": 0 }, "timestamp": 1610431327806 }
Response Body
推送成功后,您需要返回的数据内容
{ "status": 0, //0:成功,非0:失败 "description": "成功" //响应描述 }
- oauth2.0的password模式
token通过oauth2.0的password模式下获取后,再发送推送请求
字段 | 值描述 |
---|---|
Token地址 | 支持oauth2.0的password模式的授权服务地址 |
Token有效时限(秒) | 从授权服务获取到的token的有效时限 |
OauthClient | oauth2.0的client_id |
OauthSecret | oauth2.0的secret |
OauthScope | oauth2.0的scope |
账号 | oauth2.0的password模式下的username |
密码 | oauth2.0的password模式下的password |
- password模式下获取token的请求示例:
Request Headers
Content-Type: application/x-www-form-urlencoded Authorization: "Authorization","Basic " + base64Encode(client_id:secret)
Request Body
grant_type=password&username=xxx&password=base64Encode(xxx)&scope=xxx
Response Body
授权成功后,您需要返回的数据内容
{ "access_token": "xxx", //消息推送请求时使用的token "token_type": "bearer", //token的类型 "expires_in": 86399, "scope": "xxx" }
- 消息推送的请求示例:
Request Headers
Content-Type: application/json; charset=UTF-8 Authorization: "bearer " + access_token
Request Body
Request Body即消息推送内容,说明查看:可推送的消息内容
{ "id": "xxx", "type": "device_offline", "appid": "xxx", "payload": { "deviceSn": "xxx", "parentDeviceSn": null, "offline": 0 }, "timestamp": 1610431327806 }
Response Body
推送成功后,您需要返回的数据内容
{ "status": 0, //0:成功,非0:失败 "description": "成功" //状态描述 }