CCXT 401 Unauthorized Issue

Hi there,

When trying to access the API from the local machine, and IP authorised, I get this error: “AuthenticationError: coinbase GET https://api.coinbase.com/api/v3/brokerage/products 401 Unauthorized Unauthorized”

I double-checked the apiKey and secret.

Maybe some ideas?

Here is the problematic code:
import ccxt
import math
import pandas as pd
import numpy as np
import datetime
import os
import time
from datetime import datetime, timedelta

exchange = ccxt.coinbase({
‘apiKey’: ‘myapikey’,
‘secret’: ‘mysecretkey’,
‘enableRateLimit’: True, # This option enables rate limiting
})

Thank you in advance!

That is question for library author. Or use official Python SDK:

1 Like

Thank you, @muktupavels, for helping.

I have used the Python SDK, and I get the same error:
from coinbase.rest import RESTClient
from json import dumps

api_key = “0XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX”
api_secret = “-----BEGIN EC PRIVATE KEY-----\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXX//XXXXX/XXXXXXXXXXXXXXXXXXX\nXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==\n-----END EC PRIVATE KEY-----\n’”

client = RESTClient(api_key=api_key, api_secret=api_secret)

Retrieve a list of authenticated accounts for the current user

accounts = client.get_accounts()

Print the account balances in formatted JSON

print(dumps(accounts, indent=2))

API key should be in organizations/{org_id}/apiKeys/{key_id} form! And please use Preformatted text option for code.

1 Like

Are you test with their RESTClient / Python SDK? Also you should never post your keys / secrets anywhere!

1 Like