Hey All,
I am posting this as just a small bit of goodwill for the community. Particularly if you use Axios…
You signature is probably NOT invalid, confirm this by:
- Doing a GET request on /accounts in the way that it would make sense to you
If you are getting a response then don’t worry about your hashing etc… etc… thats not your issue
Next debugging step:
-
Ensure you have your headers like this:
‘CB-ACCESS-SIGN’: signature,
‘CB-ACCESS-KEY’: api_key,
‘CB-ACCESS-TIMESTAMP’: cb_access_timestamp,
‘CB-ACCESS-PASSPHRASE’: passphrase,
‘content-type’: ‘application/json; charset=UTF-8’,
‘User-Agent’: ‘request’,
The last being the potentially most important because I’m guessing you need to override whatever your request library is sending as the user agent.
If it doesn’t work then the last thing that finally got it to work for me:
- Ensure that the request body is being sent in the right way. I use axios so for me my axios config looks like:
const axiosConfig = {
method: ‘POST’,
url: ‘https://api.pro.coinbase.com/orders’,
headers,
data: buyParams,
};
** It specifically works when I did NOT use the object shorthand for buyParams **
You must have data: buyParams, or payload: buyParams or whatever ensures that the post data is nested correctly. This is actually a fairly common issue that comes with using axios (other APIs have this issue) but maybe others give much better error notifications.
So finally to the Coinbase API team… the error message Invalid Signature is completely misleading — Please, please if at least to do a small Hotfix and just update where you are sending this error message if possible.
Notice how many devs are here scrambling and guessing.
This took me 11 hours of working time to fix. It breaks various libraries as well and so much time wasted. I was about to switch to Kraken but I decided to rest and return just because so much of my codebase had been written around your APIs.
The switch from Pro → Exchange is documented SO SO SO SO poorly. I get maybe this isnt a big part of your business but for a multi billion dollar company, just throw a couple million at the problem.
Hell pay me 100k and I will take a month and rewrite your documentation from a developer standpoint. Much less than you are probably paying your current Tech Writers…
I don’t mean to be rude but look at the forums… people are CONFUSED.