'trying to send money with coinbase api (invalid signature)
i am trying to send money with the coinbase api using node js, the node js coinbase library is broken, so i am querying the api directly, it works fine for all endpoints with the GET method, when i try to use the POST method to send money i get an invalid signature error, i am almost sure it is because of the way i am sending the body, i have tried several ways and still nothing works, if someone could help me to figure out what i am doing wrong, it would be of great help, thank you in advance.
let params = {
'type': 'send',
'to': address,
'amount': '0.00001',
'currency': 'BTC',
'idem': Math.floor(Date.now() / 1000)
}
var timestamp = Math.floor(Date.now() / 1000);
var message = timestamp + 'POST' + '/v2/' + `accounts/${account_id}/transactions` + JSON.stringify(params);
var signature = crypto.createHmac('sha256', api_secret).update(message).digest('hex');
var config = {
method: 'POST',
url: `https://api.coinbase.com/v2/accounts/${account_id}/transactions`,
params: JSON.stringify(params),
headers: {
'Content-Type': 'application/json',
'CB-ACCESS-KEY': api_key,
'CB-ACCESS-SIGN': signature,
'CB-ACCESS-TIMESTAMP': Math.floor(Date.now() / 1000),
'CB-VERSION': '2016-02-18'
}
};
const response = await axios(config);
console.log(response)
```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
