Skip to content

刷新 access token 问题 #568

@turing0

Description

@turing0

问题描述

使用python实现 刷新access token的代码:

代码

def refresh_token(app_key, secret, access_token):
    new_expiration_time = datetime.now() + relativedelta(months=+3)
    expired_at = new_expiration_time.isoformat(timespec='milliseconds') + 'Z'
    print("expired_at", expired_at)
    headers = {
        'X-Api-Key': app_key,
        'Authorization': access_token,
        'X-Timestamp': str(time.time()),
        'Content-Type': 'application/json; charset=utf-8'
    }
    headers['X-Api-Signature'] = sign('GET', '/v1/token/refresh', headers, 'expired_at='+expired_at, "", secret)
    response = requests.get(
        'https://openapi.longportapp.com/v1/token/refresh',
        params={
            "expired_at": expired_at,
        },
        headers=headers
    )

    print(response)
    print(response.text)

sign是复制的文档的函数,我不知道哪里没配置对,一直提示签名错误

错误信息或结果截图
{"code":403201,"message":"signature invalid","data":null}

你的环境信息

  • 开发语言: Python

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions