Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

{"code":"400005","msg":"Invalid KC-API-SIGN"} #466

Open
BogdanSvirsky opened this issue Jun 8, 2023 · 2 comments
Open

{"code":"400005","msg":"Invalid KC-API-SIGN"} #466

BogdanSvirsky opened this issue Jun 8, 2023 · 2 comments

Comments

@BogdanSvirsky
Copy link

I started works with Kucoin API and faced with that problem:

{"code":"400005","msg":"Invalid KC-API-SIGN"}

My code here:

now = int(time.time() * 1000)
str_to_sign = str(now) + method + endpoint + json.dumps(body)
signature = base64.b64encode(
    hmac.new(self.API_SECRET.encode('utf-8'), str_to_sign.encode('utf-8'), hashlib.sha256).digest())
passphrase = base64.b64encode(
    hmac.new(self.API_SECRET.encode('utf-8'), self.PASSPHRASE.encode('utf-8'), hashlib.sha256).digest())
return {
    "KC-API-SIGN": signature,
    "KC-API-TIMESTAMP": str(now),
    "KC-API-KEY": self.API_KEY,
    "KC-API-PASSPHRASE": passphrase,
    "KC-API-KEY-VERSION": "2"
}

I've seen that many of developers faced with this problem, but nobody can solve her

@farzinsb
Copy link

I think the last part of your code is wrong , you should create header and send it with request to the server. but you are asking it in return !

my code is working like this :
headers = {
"KC-API-SIGN": signature,
"KC-API-TIMESTAMP": str(now),
"KC-API-KEY": api_key,
"KC-API-PASSPHRASE": passphrase,
"KC-API-KEY-VERSION": "2"
}
response = requests.request('get', url, headers=headers)
print(response.status_code)
print(response.json())

@BogdanSvirsky
Copy link
Author

I created a function, which return header for my requests to API. There is no mistake

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants