I tried the Coinbase Pro Node javascript library but I am getting Invalid Passphrase coming back from the authenticated endpoint, but the public endpoint works OK. I set the access key, secret key, and passphrase into my environment for my application to use. I have a valid Coinbase Pro account and I created my credentials there.
Does this work for anyone? Since the library is marked deprecated, I want to ensure I am simply not doing something wrong or using a library that doesn't work anymore.
This is my app.
const CoinbasePro = require('coinbase-pro');
const publicClient = new CoinbasePro.PublicClient();
publicClient
.getProducts()
.then(data => {
// console.log(data);
console.log(`got product data for ${data.length} products`);
})
.catch(error => {
console.log("error", error);
});
const key = process.env.cb_access_key;
const secret = process.env.cb_secret_key;
const passphrase = process.env.cb_passphrase;
const apiURI = 'https://api.pro.coinbase.com';
const sandboxURI = 'https://api-public.sandbox.pro.coinbase.com';
const authedClient = new CoinbasePro.AuthenticatedClient(
key,
secret,
passphrase,
apiURI
);
authedClient.getOrders({ after: 3000, status: 'open' }, resp => {
console.log(resp.data);
});
Response:
$ npm run cb
> coinbase@1.0.0 cb
> node coinbase.js
got product data for 375 products
{ message: 'Invalid Passphrase' }
Thanks
Notice how getProducts didn't fail even though the passphrase constant hadn't been set yet? The publicClient doesn't require a passphrase. You can get to any of those endpoints directly in a browser. For example publicClient.getProducts is simply a GET request to https://api.pro.coinbase.com/products.
I've gotten the Invalid Passphrase a couple times on API keys that have been working for days then suddenly stop. I had to delete and recreate the keys and update the code with the new keys. I'm not sure why they keys suddenly break but that is the fix for it if you haven't figured it out yet, I know this is probably a stale question by now.