Created
December 30, 2017 04:12
-
-
Save SSARCandy/26eb94bd1e45f4efaa5e4bbab76bc6c1 to your computer and use it in GitHub Desktop.
Google apps scripts for CEX.io private api auth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cex_auth(command, user_id, key, secret, callback) { | |
| var uri = "https://cex.io/api/"; | |
| var nonce = new Date().getTime(); | |
| var signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_256, nonce.toString()+user_id+key, secret); | |
| var stringSignature = signature.map(function(byte) { | |
| return ('0' + (byte & 0xFF).toString(16)).slice(-2); | |
| }).join('').toUpperCase(); | |
| var params = { | |
| "method": "post", | |
| "payload": { | |
| "key": key, | |
| "signature": stringSignature, | |
| "nonce": nonce.toString() | |
| } | |
| }; | |
| var response = UrlFetchApp.fetch(uri+command, params); | |
| var dataAll = JSON.parse(response.getContentText()); | |
| callback(dataAll); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment