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

58 lines
1.6 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: 获取调用凭证
description: 使用 appKey、appSecret 换取 V3 接口调用凭证
outline: deep
---
# 获取调用凭证
```http
POST /openapi/v3/query/token
```
说明:使用 `appKey`、`appSecret` 换取接口调用凭证。
请求体:
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| appKey | string | API 账号标识,在管理后台申请获取 |
| appSecret | string | API 密钥,在管理后台申请获取 |
| refresh | string | 是否刷新 token:`1` 强制生成新 token,`0` 或留空时尽量复用已有 token |
请求示例:
```json
{
"appKey": "YOUR_APP_ID",
"appSecret": "YOUR_APP_SECRETebdebae9763127943f097758e029a0fdbc"
}
```
响应结构:
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| data.appId | string | 客户组织编码,**后续所有接口请求体中都要传入此值** |
| data.accessToken | string | 接口调用凭证,后续放入 `X-Access-Token` |
::: info 注意:appId ≠ appKey
- **`appKey`**(如 `SDYZ`)只用于获取 token,调用 `/openapi/v3/query/token` 后就不再需要
- **`appId`**(如 `CUS-202601-0001`)由 token 接口返回,后续调用 sim-info 等接口时,请求体中的 `appId` 字段必须填这个值
- 如果传错会导致 `code: 61 "登录已过期"` 错误
:::
响应示例:
```json
{
"code": 0,
"message": "",
"data": {
"appId": "CUS-202601-0001",
"accessToken": "eyJhbGciOiJIUzI1NiJ9.eyJ1IjoiZWE3ZjJiZGY5MjQyNDFkZjg3NGIwZDMzNmZkN2UzMzEiLCJleHAiOjE3ODQ3MDAyODB9.JiYK-CXdXQKKU0UNhNOqKX5Hzyk4lVMtIpunQJDxlBI"
},
"error": null
}
```