emmtte / list

Google Sheets automatic creation with Google Apps Script (GAS) for managing a cryptocurrency tracking spreadsheet with multi exchanges

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kucoin API update

Popcorn2018 opened this issue · comments

Hi,

Not sure if you're updating this but Kucoin has upgraded their API and the old code doesn't work.

Seems to want a 44 character signature, not 64.

Fix for kucoin v2:

var nowDate = new Date().getTime();

var nowStr = '' + nowDate;
var strForSign = nowStr + 'GET' + '/api/v1/accounts'+''
var signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_256, strForSign, secret);

var url = 'https://api.kucoin.com/api/v1/accounts';
var options = {
'headers' : {
'KC-API-KEY': key,
'KC-API-TIMESTAMP': nowStr,
'KC-API-SIGN': Utilities.base64Encode(signature),
'KC-API-PASSPHRASE': 'pass-from-'
}
}

var jsondata = UrlFetchApp.fetch(url, options);

Hi guys, I keep getting "Invalid KC-API-PASSPHRASE". Any ideas?

Hi guys, I keep getting "Invalid KC-API-PASSPHRASE". Any ideas?

Fixed it - if the API key is V2 then the passphrase needs to be sent encrypted in the same way that the signature is

Pull request accepted