danpaquin / coinbasepro-python

The unofficial Python client for the Coinbase Pro API
MIT License
1.82k stars 737 forks source link

TImestamp expired error #174

Closed andrewbain closed 5 years ago

andrewbain commented 6 years ago

I am getting an error when requesting my account, public client request working ok

mcardillo55 commented 6 years ago

Can you paste the output of the error?

philipodonnell commented 6 years ago
import gdax
key = '***'
b64secret = '***'
passphrase = '***'
auth_client = gdax.AuthenticatedClient(key, b64secret, passphrase, api_url="https://api-public.sandbox.gdax.com")
print(auth_client.get_accounts())

Connected to pydev debugger (build 163.8233.8) {'message': 'request timestamp expired'}

philipodonnell commented 6 years ago

I have the same issue and its driving me insane. I get the same error with the node apis and the python ones. The API keys are definitely correct. I get the same error using the sandbox api and the live api. My system clock is definitely correct.

acontry commented 6 years ago

This could be an issue with your machine's local time, since a timestamp is used in authentication. GDAX offers an endpoint to get their timestamp, which you can use to compare against your local machine and check for any weird problems.

Edit: Compare that endpoint output directly to:

import time
time.time()
philipodonnell commented 6 years ago
import time
import gdax
public_client = gdax.PublicClient()
print(time.time(), public_client.get_time())

yields

1512978159.8325033 {'epoch': 1512978191.837, 'iso': '2017-12-11T07:43:11.837Z'}

The iso time is correct except my timezone is EST. The epoch and my computer time don't match exactly, but surely that's due to the time zones? Does this library require the computer time to be in GMT+0?

philipodonnell commented 6 years ago

I set my computer to GMT+0 just to test but it didn't work either.

acontry commented 6 years ago

Looks like you have about 30 seconds difference between your computer and GDAX. Maybe sync your local time to internet time and retry? Just my best guess.

andrewbain commented 6 years ago

I just reset my time using auto setting for my area and it now seems to work

philipodonnell commented 6 years ago

1513008013.3986995 {'epoch': 1513008013.502, 'iso': '2017-12-11T16:00:13.502Z'}

I didn't do anything but now it works. Did my clock suddenly sync overnight? What are the odds of that?

acontry commented 6 years ago

@philipodonnell Your clock usually does sync overnight :)

seomradubh commented 5 years ago

I had a similar issue, and a few goes at the time sync options in windows 10 sorted it for me, thanks all.

Here is the code I used to see if the local machine time is similar to the coinbase servers:

import cbpro import datetime auth_client = cbpro.AuthenticatedClient(key, b64secret, passphrase) #I didnt try this with public print(auth_client.get_time()) print(datetime.datetime.utcnow())