Been at this for a week: every, single, day. Nothing is working. How hard is it for a minimal authentication? I bet so many people are looking for this answer too.
Here is rough-draft of what we've got so far:
import cbpro, hmac, hashlib, time,
api_key = "[YOUR_API_KEY]"
secret_key = "[YOUR_B64SECRET]"
passphrase = "[YOUR_PASSPHRASE]"
message = message.encode('ascii')
hmac_key = base64.b64decode(secret_key)
signature = hmac.new(hmac_key, message, hashlib.sha256)
signature_b64 = base64.b64encode(signature.digest()).decode('utf-8')
auth_client = cbpro.AuthenticatedClient(api_key, signature_b64, passphrase)
auth_client.get_accounts()
or while subscribing with websockets, something with this:
{
"type": "subscribe",
"product_ids": [
"BTC-USD"
],
"channels": ["full"],
"signature": "...",
"key": "...",
"passphrase": "...",
"timestamp": "..."
}
using:
socket = "wss://ws-feed.pro.coinbase.com"
ws = websocket.WebSocketApp(socket, on_open=on_open, on_message=on_message)
ws.run_forever()
I dont understand why a simply few lines of code to authenticate and view open orders/account is so hard, while subscribing to the websocket ticker and receiving price changes is so easy. Encoding the secret key shouldnt be too hard? Please help us with a super short and simple example (without all the "init"s and imports and different functions with passing). Sheesh