Closed zhsolutions closed 8 years ago
I'm not able to reproduce this. Does it only occur on the sandbox?
Which version of the library are you using? As far as I can tell, we don't set the expire header in this library.
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..
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.
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 ?
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.
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
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.
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.
@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...
sudo ntpdate -u it.pool.ntp.org
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.
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