跳转至

密钥鉴权

调用地址:登录域名 (不清楚请联系我们)

POST /prod-api/auth/authentication

通过appKey和secret,换取用于请求其他api的token。 expires_in为有效时长单位S,超过该时间,token将会失效,需重新获取。 每次请求api时,将会重新计算该token的有效时长。

调用示例

以下示例演示如何换取 token,并在后续 API 请求中携带鉴权信息。请将 {登录域名}appKeysecret 替换为实际值。

1. 获取 Token

curl -X POST 'https://{登录域名}/prod-api/auth/authentication' \
  -H 'Content-Type: application/json' \
  -d '{
    "appKey": "e033856fb670c1e1a5d3db4e512b318a",
    "secret": "93ad670831d47130217cde1a0114d4e3"
  }'

成功时返回示例:

{
  "expires_in": "120",
  "access_token": "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
}

说明:expires_in120 表示该 token 有效期为 120 秒;超时后需重新调用本接口获取。

2. 使用 Token 调用其他 API

将返回的 access_token 放入请求头 Authorization,格式为 Bearer {access_token}

curl -X GET 'https://{登录域名}/prod-api/xxx/xxx' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.xxxxxx'

Body 请求参数

{
  "appKey": "e033856fb670c1e1a5d3db4e512b318a",
  "secret": "93ad670831d47130217cde1a0114d4e3"
}

请求参数

名称 位置 类型 必选 中文名 说明
body body object none
» appKey body string appkey none
» secret body string secret none

返回示例

200 Response

{
  "expires_in": "120",
  "access_token": "eyJhbGciOiJIUzUxMiJ9.xxxxxx"
}

返回结果

状态码 状态码含义 说明 数据模型
200 OK 成功 Inline

返回数据结构

状态码 200

名称 类型 必选 约束 中文名 说明
» expires_in string true none access_token的有效期时长
» access_token string true none token

数据模型