Files
iotlcm/docs/openapi/operator/shared-token/index.md
T
2026-10-26 15:30:14 +08:00

88 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: 共享 Token 接口
description: 共享 Token 接口说明
outline: deep
---
# 共享 Token 接口
本接口用于获取平台已开放共享权限的移动运营商访问 Token。客户无需直接维护运营商应用密钥,平台根据客户已授权的通道配置完成校验并向运营商申请 Token。
## 服务地址
```text
https://api.iotlcm.example.com
```
HTTP(`http://api.iotlcm.example.com`)仅为存量兼容保留,不做自动跳转,新接入请使用 HTTPS。
## 接口信息
```http
POST /openapi/v3/query/operator-token
```
请求头:`Content-Type: application/json`。
请求体:
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `appId` | string | 平台分配的客户应用标识 |
| `chanKey` | string | 已开通共享 Token 权限的通道标识 |
请求示例:
```json
{
"appId": "7s9g2p5n8z1d4m6r",
"chanKey": "channel_010"
}
```
响应中的 `data.accessToken` 用于调用移动运营商 V5 接口。Token 的有效期以 `data.tokenExpire` 为准,请勿将 Token 写入代码仓库或日志。
响应示例:
失败时,接口返回的 `data` 为 `{}`,不是 `null`;例如 `code=50` 表示平台侧获取运营商 Token 失败。
```json
{
"code": 0,
"message": "",
"data": {
"chanAlias": "中国移动物联网",
"chanKey": "channel_010",
"accessToken": "YOUR_ACCESS_TOKENf3515b3bdaeca904dd2e904061b65e8153",
"tokenExpire": "2026-09-09 16:00:00"
},
"error": null
}
```
## 字段说明
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| `code` | number | 平台业务状态码,`0` 表示成功;`50` 表示平台侧获取运营商 Token 失败 |
| `message` | string | 错误或提示信息 |
| `data` | object | 成功时返回 Token 信息;失败时返回空对象 `{}`,不是 `null` |
| `data.chanAlias` | string | 通道名称 |
| `data.chanKey` | string | 通道标识 |
| `data.accessToken` | string | 移动运营商接口访问 Token |
| `data.tokenExpire` | string | Token 过期时间 |
| `error` | any | 错误详情;无错误时通常为 `null` |
## 调用示例
```bash
curl --request POST \
--url https://api.iotlcm.example.com/openapi/v3/query/operator-token \
--header 'Content-Type: application/json' \
--data '{
"appId": "7s9g2p5n8z1d4m6r",
"chanKey": "channel_010"
}'
```
共享 Token 仅适用于已开通共享权限的通道。若通道未授权、客户应用标识与通道不匹配,或运营商 Token 获取失败,接口将返回失败信息。