'Gate io error INVALID_SIGNATURE in app script
I try to get data from Exchange Gate.io by app script. This is my code:
function data() {
var key = "***"
var sec = "***"
var timestamp = Math.floor(Date.now() / 1000)
var base = "https://api.gateio.ws";
var prefix = "/api/v4"
var pat = '/wallet/total_balance'
var sign = "timestamp=" + timestamp;
Logger.log(sign)
var signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_512, sign, sec);
signature = signature.map(function(e) {
var v = (e < 0 ? e + 256 : e).toString(16);
return v.length == 1 ? "0" + v : v;
}).join("");
var params = {
'method': "get",
'headers': {
'Accept': 'application/json',
'Content-Type': 'application/json',
'KEY': key,
'Timestamp': timestamp,
'SIGN': signature,
},
'muteHttpExceptions': true,
};
var data = UrlFetchApp.fetch(base + prefix + pat, headers=params);
Logger.log(data)
}
I get the error:
{"label":"INVALID_SIGNATURE","message":"Signature mismatch"}
The Keys is valid problem in code.
to learn more check that: https://www.gate.io/docs/apiv4/en/#retrieve-user-s-total-balances
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
