Getting Invalid request

This is my code, hiding the API secret
import json, hmac, hashlib, time, base64,requests
timestamp = str(int(time.time()))
secretKey = ‘*************’ #key hidden
method = ‘GET’
path_url = ‘/api/v3/brokerage/accounts’
message = timestamp + ‘GET’ + path_url + ‘’
signature =‘utf-8’), message.encode(‘utf-8’), digestmod=hashlib.sha256).digest()
headers = {
“Content-Type”: “application/json”,
“CB-ACCESS-KEY”: secretKey,
“CB-ACCESS-SIGN”: signature,
url = “
response= requests.get(url, headers=headers)
print (response.text)

Can someone please assist why I am getting invalid API request

changed .digest() to .hexdigest()
now getting unauthorized 401 response

Hello there @srpatel140! Welcome to the forum. For the details regarding your concern, we will check on this for you with our team. We will get back to you once we have more information. Keep in touch!

Hello @srpatel140! After consulting your issue with the team, they have noticed that you are passing the secretKey instead of the API key for the CB-ACCESS-KEY. You may look at this documentation for reference.

We hope we were able to provide clarification with regard to your issue. Please do not hesitate to reply back to the thread if you have any other inquiries in mind.

1 Like