Skip to content

Instantly share code, notes, and snippets.

@tyomo4ka
Last active May 8, 2023 12:55
Show Gist options
  • Save tyomo4ka/4cc942f67e19e54679e623699bb1746a to your computer and use it in GitHub Desktop.
Save tyomo4ka/4cc942f67e19e54679e623699bb1746a to your computer and use it in GitHub Desktop.
Requests signing using HMAC authentication with TYK Gateway
# An example of adding requests signature using HMAC authentication with TYK Gateway.
var sdk = require('postman-collection'),
apiKey = environment.api_key,
apiSecret = environment.api_secret,
date = (new Date()).toUTCString(),
signatureContentString = 'date: ' + date,
signatureString = CryptoJS.HmacSHA1(signatureContentString, apiSecret).toString(CryptoJS.enc.Base64),
authHeader = 'Signature keyId="' + apiKey + '",algorithm="hmac-sha1",signature="' + encodeURIComponent(signatureString) + '"';
pm.environment.set("authHeader", authHeader);
pm.environment.set("date", date);
# Use these variables in Authorization header and Date header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment