Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

Request timestamp expired #65

Closed
zhsolutions opened this issue Oct 8, 2015 · 12 comments
Closed

Request timestamp expired #65

zhsolutions opened this issue Oct 8, 2015 · 12 comments

Comments

@zhsolutions
Copy link

Just installed this library and when I try to generate a new chekout, the following exception results

https://sandbox.coinbase.com/checkouts/Caught%20exception:%20request%20timestamp%20expired

@aianus
Copy link
Contributor

aianus commented Oct 11, 2015

I'm not able to reproduce this. Does it only occur on the sandbox?

@aianus
Copy link
Contributor

aianus commented Oct 11, 2015

Which version of the library are you using? As far as I can tell, we don't set the expire header in this library.

@zhsolutions
Copy link
Author

Maybe its only in sandbox, i did not try live

CB-ACCESS-TIMESTAMP - Required to interact with API
The CB-ACCESS-TIMESTAMP header MUST be number of seconds since Unix Epoch.
Your timestamp must be within 30 seconds of the api service time or your request will be considered expired and rejected. We recommend using the time endpoint to query for the API server time if you believe there many be time skew between your server and the API servers.

So, I would imagine this library would support the CB-ACCESS-TIMESTAMP..

@aianus
Copy link
Contributor

aianus commented Oct 12, 2015

I apologize, you're right, the library does set the CB-ACCESS-TIMESTAMP header.

Are you using NTP on the machine that's sending these requests? If your time is off from our time by more than one minute, the requests would fail with the error you're seeing.

@francisco-gamonal
Copy link

I have the same problem when using this package , initially if transactions processed but at any moment stopped working and is in sandbox mode.

Here I detail the error codes using laravel 5.1.

Controller
-------------

$apiKey = 'xxxxxxxxx';
$apiSecret = 'xxxxxxxxxxxxxx;

$configuration = Configuration::apiKey($coinbaseAPIKey, $coinbaseAPISecret);
//$configuration->setApiUrl(Configuration::SANDBOX_API_URL);
$client = Client::create($configuration);

$checkout = new Checkout([
      'amount' => new Money($pack->amount, CurrencyCode::EUR),
      'name' => 'Buy '. $pack,
      'cancel_url' => "http://".$domain."/buy/coinbasecancel",
      'success_url' => "http://".$domain."/buy/coinbasesuccess"
]);

$client->createCheckout($checkout);

View
-------
Error #2
AuthenticationException in HttpException.php line 37:
request timestamp expired

Error #1
ClientException in Middleware.php line 69:
Client error: 401

All REST requests must contain the following headers, according to official documents
(docs coinbase)

currently no way to set in the request header CB -ACCESS TIMESTAMP ?

@aianus
Copy link
Contributor

aianus commented Nov 6, 2015

Does your system sync its clock via NTP? Force a sync and make sure your system's time is within 30 seconds of the current time.

@francisco-gamonal
Copy link

Hi @aianus at the moment he was not using NTP , and install it in my development environment and now if transactions work.

I will be discussing in a few days to see if the problem persists.

Thanks a lot for the help

@mabasic
Copy link

mabasic commented Nov 25, 2015

I had the same issue. Solved it by restarting my local development virtual machine. Somehow its internal clock was wrong after suspend, so the restart solved it.

@aianus aianus closed this as completed Jan 8, 2016
@KonstantinKolodnitsky
Copy link

Why this issue is closed? There is no solution.
I've just faced that issue on the live server where I don't have access to.

@aianus
Copy link
Contributor

aianus commented Jan 15, 2016

@KonstantinKolodnitsky

You can work around the issue by subclassing ApiKeyAuthentication and overriding the getTimestamp() method. Then build a configuration and client from your subclass

$auth = new YourSubclass($apiKey, $apiSecret);
$configuration = new Configuration($auth);
$client = Client::create($configuration);

But I highly suggest yelling at your hosting provider or switching to a new one if they're incapable of keeping their system time accurate...

@ninazu
Copy link

ninazu commented Dec 28, 2016

sudo ntpdate -u it.pool.ntp.org

@dandittach
Copy link

Had this issue, and it turned out that the default time sync for my Mac (Apple Americas) was about 5 s off NTP. Switched in my Date & Time prefs to using Apple Europe, and it works fine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

7 participants