E
E
europeexpress2021-02-20 11:28:59
Python
europeexpress, 2021-02-20 11:28:59

How to write a signature for a request?

How to write a signature? Previous attempts have failed. Developer serialization - https://docs.kuna.io/docs/api-data-schema-and-seri... There are no Python libraries. Here is the code I made up. There is no understanding. Help, understand or give a link where you can understand how to do this. My code

r = 'https://api.kuna.io/v3/auth/me'
timestamp = str(int(time.time()))
msg = str(r) + str(public_key) + str(timestamp)

kun_signature = hmac.new(secret_key.encode('ascii'), msg.encode('ascii'), hashlib.sha384).hexdigest()
headers = {'accept': 'application/json',
'content-type': 'application/json',
'kun-nonce': timestamp,
'kun-apikey': public_key,
'kun-signature': kun_signature}

pool = requests.post(r, headers=headers)
print(pool)

Conclusion How to make such a signature? UPD. There is an old library written in 2018 by one author. It has different signature requirements, so it doesn't work.
<Response [400]>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
europeexpress, 2021-02-21
@europeexpress

This is how the signature for kuna.io is created

r = 'https://api.kuna.io/v3/auth/me'    
api_path = "/v3/auth/me"
nonce = str(int(time.time()*1000.0))
body = str('')
msg = api_path+nonce+body
print(msg)
kun_signature = hmac.new(secret_key.encode('ascii'), msg.encode('ascii'), hashlib.sha384).hexdigest()
headers = {'accept': 'application/json',
'content-type': 'application/json',
'kun-nonce': nonce,
'kun-apikey': public_key,
'kun-signature': kun_signature}

pool = requests.post(r, headers=headers)
print(pool.text)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question