-
-
Save nCally/508d449fb5ae8bfee62cde290850d112 to your computer and use it in GitHub Desktop.
To reduce the time to find what to do if you're new to doing pre-script
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
const token = pm.environment.get('token'); | |
const accessSecret = pm.environment.get('accessSecret'); | |
// i don't know if the next line works for query params yet | |
const body = JSON.parse(pm.request.body.raw); | |
let sigPayload = ''; | |
for (item in body) { | |
sigPayload += item + "=" + body[item] + "&"; | |
} | |
const text = sigPayload + "api-key="+token+"&api-secret="+accessSecret; | |
const hash = CryptoJS.HmacSHA256(text, accessSecret); | |
const hashBase64 = CryptoJS.enc.Base64.stringify(hash); | |
pm.environment.set("hmac", hashBase64); | |
pm.environment.set("token", token); | |
pm.environment.set("timestamp", Date.now()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment