api-key 换取用户令牌(token)

说明

在功能接口中携带token令牌用于用户身份信息校验, 当前token令牌有效期为1天, 超期后需要通过api-key参数值, 调用接口获取新值

续租接口

接口地址

https://www.hidreamai.com/prod-api/user/apikey2token

请求方式

GET

请求参数

Header

参数 类型 是否必填 说明
Api-Key string api-key获取接口中api_key参数值

curl示例:

curl -X GET -v 'https://www.hidreamai.com/prod-api/user/apikey2token' -H 'Api-Key: eyJhbGciOiJIUzI.......'

python示例:

import requests


api_key = ''

headers = {
    "Api-Key": api_key
}

url = "https://www.hidreamai.com/prod-api/user/apikey2token"
response = requests.get(url, headers=headers)

if response.status_code == 200:
    if response.json().get('code') == 0:
        print(response.json().get('result').get('token'))
    else:
        # 接口异常
        print(response.json())
else:
    # http请求异常
    print(response.status_code)

返回参数

参数 类型 说明
code int 返回状态码
message string 返回状态信息
request_id string 本次请求的ID
result dict 返回结果

其中返回结果 result字段具体为:

参数 类型 说明
token string token值
expire_time string api-key过期时间 (格式: RFC3339)

示例:

{
    "code": 0,
    "message": "Success",
    "request_id": "45debd04-b998-11ee-8fe0-2e0412837ce4",
    "result": {
        "expire_time": "2024-01-25T03:49:10.601343+00:00",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.56GrjufAVpoypabD........."
    }
}

results matching ""

    No results matching ""

    results matching ""

      No results matching ""