PostMan

Summary: Author: 张亚飞 | 阅读时间: 1 minute read | Published: 2015-03-30
Filed under Categories: LinuxTags: Note,

PostMan

PostMan 自动签名

[](https://gist.github.com/michoelchaikin/2a4916e0917aa0f79b8eb9d7fe275363)

let account = pm.environment.get("account");
let consumerKey = pm.environment.get("consumerKey");
let consumerSecret = pm.environment.get("consumerSecret");
let tokenId = pm.environment.get("tokenId");
let tokenSecret = pm.environment.get("tokenSecret");
    
let timestamp = new Date().getTime().toString().substring(0, 10);
let nonce = CryptoJS.lib.WordArray.random(10).toString();
let baseString = `${account}&${consumerKey}&${tokenId}&${nonce}&${timestamp}`;
let key = `${consumerSecret}&${tokenSecret}`;
let signature = CryptoJS.HmacSHA1(baseString, key).toString(CryptoJS.enc.Base64);

pm.environment.set("signature", signature);
pm.environment.set("nonce", nonce);
pm.environment.set("timestamp", timestamp);

Comments

Cor-Ethan, the beverage → www.iirii.com