permanentKey换取tempKey
查看文档来源信息
- 来源目录:
addons/sys_base/docs - 来源文件:
接口文档/70-permanentKey换取tempKey.md
详细说明
用于使用应用的 permanent key 换取正式运行时使用的 tempKey。应用端或服务端调用需要携带 X-App-Key 的公共认证接口前,必须先通过本接口换取 tempKey。
permanent key 只用于换取 tempKey,不允许直接作为运行态 X-App-Key 长期使用。tempKey 默认有效期为 2 小时,到期后调用方需要重新换取。
接口信息
| 项目 | 内容 |
|---|---|
| 请求方式 | POST |
| 请求路径 | /sys_base/public/auth/exchangeTempKey |
| 来源文件 | 接口文档/70-permanentKey换取tempKey.md |
请求头
| 请求头 | 示例值 | 说明 |
|---|---|---|
Content-Type | application/json | 请求体格式。 |
app-id | mid-admin | 当前应用 ID。 |
入参
json
{
"appUuid": "mid-admin",
"key": "pk_20260426_xxxxxxxxxxxxx"
}参数说明
| 参数 | 类型 | 是否必填 | 示例 | 说明 |
|---|---|---|---|---|
appUuid | string | 否 | mid-admin | 应用 UUID;为空时回退到请求头 app-id |
key | string | 是 | pk_20260426_xxx | permanent key 明文 |
请求示例
当前文档未提供独立请求示例,请参考下方 curl 示例。
响应输出
json
{
"code": 0,
"msg": "换取成功",
"data": {
"tempKey": "6f0b8c0d...",
"expiresInSeconds": 7200
}
}字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
data.tempKey | string | 运行时使用的 tempKey |
data.expiresInSeconds | number | tempKey 有效秒数 |
curl 示例
bash
curl --location --request POST 'http://127.0.0.1:8100/sys_base/public/auth/exchangeTempKey' \
--header 'Content-Type: application/json' \
--header 'app-id: mid-admin' \
--data-raw '{
"key": "pk_20260426_xxxxxxxxxxxxx"
}'