Skip to content

Instantly share code, notes, and snippets.

@pixelpylon
Created February 23, 2021 21:09
Show Gist options
  • Save pixelpylon/d94788e3861e26bd3e04a76b022bf2ef to your computer and use it in GitHub Desktop.
Save pixelpylon/d94788e3861e26bd3e04a76b022bf2ef to your computer and use it in GitHub Desktop.
postman pre-script to obtain bokun signature
const moment = require('moment');
let timestamp = moment().utc().format("YYYY-MM-DD HH:mm:ss");
pm.globals.set("timestamp", timestamp);
const access = "ACCESS_KEY";
let csting = timestamp+access+"GET"+pm.request.url.getPathWithQuery();
const secret = "SECRET_KEY";
const hmac = CryptoJS.HmacSHA1(csting, secret);
const signature = hmac.toString(CryptoJS.enc.Base64);
pm.globals.set("signature", signature);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment