gpt4 book ai didi

python - 不确定如何验证我的 api key Kucoin

转载 作者:太空宇宙 更新时间:2023-11-03 14:23:30 26 4
gpt4 key购买 nike

我正在学习如何使用 Kucoin,但在向 API 服务器验证自己身份时遇到问题。

我正在尝试加载所有有效订单,但不断收到 401 错误。

Kucoin API 文档指出我需要添加以下内容:

{
"KC-API-KEY": "59c5ecfe18497f5394ded813",
"KC-API-NONCE" : 1506219855000 //Client timestamp (exact to
milliseconds), before using the calibration time, the server does not
accept calls with a time difference of more than 3 seconds
"KC-API-SIGNATURE" :
"fd83147802c361575bbe72fef32ba90dcb364d388d05cb909c1a6e832f6ca3ac"
//signature after client encryption
}

作为请求 header 的参数。我不确定这意味着什么。任何帮助将不胜感激。

最佳答案

创建 header 可能有点棘手。

对于随机数值或任何毫秒时间戳值,我发现生成它的最佳方法如下

import time
int(time.time() * 1000)

签名要求您以查询字符串格式按字母顺序对参数进行排序,将其与路径和随机数结合起来,然后使用 sha256 和您的 key 对字符串进行哈希处理。

如果您想自己实现它,请随意从这里复制代码,它分为几个函数,应该非常可读 https://github.com/sammchardy/python-kucoin/blob/0ece729c406056a428a57853345c9931d449be02/kucoin/client.py#L117

或者您可能最好只使用该库。 (注:我是 python-kucoin 的作者和维护者)

关于python - 不确定如何验证我的 api key Kucoin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47785751/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com