Skip to content

Instantly share code, notes, and snippets.

@ehpc
Created September 17, 2019 11:27
Show Gist options
  • Save ehpc/af8cfb8be01c18c180fc80ecdc8bce2b to your computer and use it in GitHub Desktop.
Save ehpc/af8cfb8be01c18c180fc80ecdc8bce2b to your computer and use it in GitHub Desktop.
Code for managing Binance authentication with Postman
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