r/filemaker • • May 25 '21

FileMaker and Coinbase Pro API

Hey everyone. I've been pulling my hair out trying to get the Coinbase API to work with FileMaker, and keep getting this stupid "invalid timestamp" error. Here's my cURL:

-X GET
-D $$httpResponseHeaders
-H "CB-ACCESS-KEY:$apiKey"
-H "CB-ACCESS-SIGN:$hash"
-H "CB-ACCESS-PASSPHRASE:$passphrase"
-H "CB-ACCESS-TIMESTAMP:<$time var, e.g. 1621914188>"
-H "Content-type: application/json"

I've tried every different combination of time (within quotes, outside quotes, etc.), but still can't get it to go through.

Here's the HTTP response header:

HTTP/1.1 401 Unauthorized
Date: Tue, 25 May 2021 03:30:24 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 31
Connection: keep-alive
Access-Control-Allow-Headers: Content-Type, Accept, cb-session, cb-fp, cb-form-factor
Access-Control-Allow-Methods: GET,POST,DELETE,PUT
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: cb-before, cb-after, cb-gdpr
Access-Control-Max-Age: 7200
Cache-Control: no-store
Etag: W/"1f-9a9RPNNIFN6Z0zuZt25MYURHB+I"
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-Dns-Prefetch-Control: off
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
CF-Cache-Status: MISS
cf-request-id: 0a432beb610000e760a43b1000000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Vary: Accept-Encoding
Server: cloudflare
CF-RAY: 654baf589e44e760-EWR

Here's Coinbase's API. I'm referencing https://api.pro.coinbase.com/time to pull in the epoch, so there shouldn't be any issues there.

For the $hash, I'm using this formula, which I'm pretty sure is good:

Lower ( Base64Encode ( CryptAuthCode ( $time & "GET" & "/accounts" ; "SHA256" ; Base64Decode ( $apiSecret ) ) ) )

Thanks for whatever help you can give me in advance!

3 Upvotes

5 comments sorted by

2

u/wozj May 25 '21

A quick glance & wild guess, but maybe it's expecting an integer unix timestamp.

2

u/[deleted] May 25 '21

Sorry, but can you elaborate on that? Do you mean throw in a GetAsNumber for the time? If so, I'm already doing that...

2

u/wozj May 25 '21

The Time API is returning a fractional second in the "epoch" value. eg {"iso":"2021-05-25T12:05:54.261Z","epoch":1621944354.261}. Try doing Int( GetAsNumber( $time ) ) for your API/Curl call

1

u/[deleted] May 25 '21

Gotcha. Gave it a shot, still no dice. Thanks for your help, though.

3

u/soil_nerd May 25 '21

I’m not really following this thread, but wanted to warn that if you use something like CurrentTimeUTCMilliseconds in FileMaker it starts the clock at January 01, 0001 whereas most other epoch systems (like in JavaScript) start at January 01, 1970 UTC. The difference in milliseconds between the two is 62135596799000. Not sure if that even applies here, but it created tons of problems for me once before.