I have the following code:
import hmac
import hashlib
import json
import time
from urllib.parse import urlencode
import requests
access_key = 'cb3e8274-bg2rg65tmn-02ar6g57-c7a5'
secret_key = '365ca06e-72fege10-f11218c6-1423f'
def sign(secret_key, data):
digest = hmac.new(bytes(secret_key, 'utf-8'), bytes(data, 'utf-8'), hashlib.sha256).digest()
return digest.hex()
params = {
'AccessKeyId': access_key,
'SignatureMethod': 'HmacSHA256',
'SignatureVersion': '2',
'Timestamp': time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime()),
}
query_string = urlencode(sorted(params.items()))
signature = sign(secret_key, f"GET\napi.huobi.pro\n/v1/query/deposit-withdraw\n{query_string}")
params['Signature'] = signature
url = f"https://api.huobi.pro/v1/query/deposit-withdraw?{query_string}&Signature={signature}"
response = requests.get(url)
data = response.json()
with open('wHuobi.json', 'w') as f:
json.dump(data, f)
Но после успешного выполнения кода в файле wHuobi.json высвечивается ошибка:
{"status": "error", "err-code": "api-signature-not-valid", "err-msg": "Signature not valid: Incorrect Access key [Access key\u9519\u8bef]", "data": null}
I searched the internet for a solution, but the solution was different for everyone and not in Python