Created
May 25, 2017 15:29
-
-
Save ctrlaltdylan/dd75426527d424bc7a4e93bc6a52ea95 to your computer and use it in GitHub Desktop.
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
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ctrlaltdylan is the public key in this example the access_id from the ruby example? Im struggling building a JS lib for this.