Error 401 - Invalid API Key


I’m starting a new project using Coinbase’s Advance API but I can not do any request

I have created an API key (more than 2 days ago) and I’m still receiving the error “Invalid API Key” (my API KEY has all the permissions enabled)

Could you review my code and tell me if I’m doing something wrong? I have tried different URLs but all return the same error (I have tried with 2 differents API Keys too)

def doRequest(type, url):
    conn = http.client.HTTPSConnection("")
    payload = ''
    userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36"
    contentType = "application/json"
    accessKey = "MY_ACCESS_KEY"
    timestamp = str(int(time.time())) 
    accessSign = getAccessSing(timestamp, type, url, payload)
    headers = {
        "User-Agent": userAgent, "Content-Type": contentType, "CB-ACCESS-KEY": accessKey, "CB-ACCESS-SIGN" : accessSign, "CB-ACCESS-TIMESTAMP": timestamp
    conn.request(type, url, payload, headers)
    res = conn.getresponse()
    data =
    data = data.decode("utf-8")
    return data

def getAccessSing(timestamp, method, url, body):
    key = "MY_SECRET_KEY"
    message = timestamp + method + url + body
    signature ='utf-8'), message.encode('utf-8'), digestmod=hashlib.sha256).digest()
    return signature.hex()

def doWork():
    doRequest("GET", "/api/v3/brokerage/products")

Ups :man_facepalming: :man_facepalming: :man_facepalming:
Thanks you so much @muktupavels