Last active
May 8, 2023 12:55
-
-
Save tyomo4ka/4cc942f67e19e54679e623699bb1746a to your computer and use it in GitHub Desktop.
Requests signing using HMAC authentication with TYK Gateway
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
# 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