Created
September 17, 2019 11:27
-
-
Save ehpc/af8cfb8be01c18c180fc80ecdc8bce2b to your computer and use it in GitHub Desktop.
Code for managing Binance authentication with Postman
This file contains 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
let secret = pm.variables.get('secret-key'), | |
timestamp = Date.now(), | |
query = pm.request.url.query | |
.filter(x => !x.disabled && x.key !== 'signature') | |
.map(x => { | |
if (x.key === 'timestamp') { | |
return `${x.key}=${timestamp}`; | |
} | |
else { | |
return `${x.key}=${x.value}`; | |
} | |
}) | |
.join('&'), | |
signature = CryptoJS.HmacSHA256(query, secret).toString(CryptoJS.enc.Hex); | |
pm.globals.set('timestamp', timestamp); | |
pm.globals.set('signature', signature); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment