bitvavo / node-bitvavo-api

Node wrapper for the Bitvavo API
ISC License
19 stars 15 forks source link

errorCode: 301, error: 'API Key must be of length 64.' #13

Open Alifar opened 3 years ago

Alifar commented 3 years ago

I have tripple checked my API key and secret and are correct but still gives me the following error: errorCode: 301, error: 'API Key must be of length 64.'

const createSignature = function (timestamp, method, url, body) {
let string = timestamp + method + '/v2' + url;
 if (Object.keys(body).length !== 0) {
string += JSON.stringify(body);
}
let signature = crypto
.createHmac('sha256', process.env.API_SECRET)
.update(string)
.digest('hex');
return signature;
};
var sig = createSignature(Date.now(), 'GET', '/balance', {});

bitvavo.balance(
{
  headers: {
    'Bitvavo-Access-Key': process.env.API_KEY,
    'Bitvavo-Access-Signature': sig,
    'Bitvavo-Access-Timestamp': Date.now(),
    'Bitvavo-Access-Window': 10000,
  },
},
(error, response) => {
  if (error === null) {
    console.log(response);
  } else {
    console.log(error);
  }
});

Note: even without setting the headers it gives me the same error

bitvavo.balance({}, (error, response) => {
  if (error === null) {
    console.log(response);
  } else {
    console.log(error);
  }
});

I can access all other endpoints from the API just fine

timrijkse commented 3 years ago

I'm having the same issue with all private methods (balance, orders etc)

niodad commented 2 years ago

I think you need the application/json header, that solved this for me