Skip to content

Instantly share code, notes, and snippets.

@ctrlaltdylan
Created May 25, 2017 15:29
Show Gist options
  • Save ctrlaltdylan/dd75426527d424bc7a4e93bc6a52ea95 to your computer and use it in GitHub Desktop.
Save ctrlaltdylan/dd75426527d424bc7a4e93bc6a52ea95 to your computer and use it in GitHub Desktop.
var private_key = postman.getEnvironmentVariable('private_key');
var public_key = postman.getEnvironmentVariable('public_key');
var method = request.method;
var content_type = 'application/json';
var content_md5 = '';
var request_url = request.url;
var request_uri = request_url.replace(/^.*\/\/[^\/]+/, '')
var timestamp = (new Date()).toGMTString();
// 'http method,content-type,content-MD5,request URI,timestamp'
var signature = [method, content_type, content_md5, request_uri, timestamp].join(',');
var encrypted_signature = 'APIAuth ' + public_key + ':' + CryptoJS.HmacSHA1(signature, private_key).toString(CryptoJS.enc.Base64);
postman.setEnvironmentVariable('timestamp', timestamp);
postman.setEnvironmentVariable('encrypted_signature', encrypted_signature);
postman.setEnvironmentVariable('content_type', content_type);
@mbround18
Copy link

@ctrlaltdylan is the public key in this example the access_id from the ruby example? Im struggling building a JS lib for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment