Created
June 24, 2020 15:30
-
-
Save edunuzzi/6fe33ff26a60a6a398fa2e2e855c30d6 to your computer and use it in GitHub Desktop.
Um pequeno exemplo de autenticação na API da Swipe utilizando NodeJS
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
const CryptoJS = require("crypto-js") | |
const apiKey = "<minha apiKey>" | |
const secret = "<meu secret>" | |
const method = "GET" | |
const timestamp = Math.floor(new Date().getTime / 1000) // em segundos | |
const path = "/ledger/" | |
const hmac = CryptoJS.HmacSHA256( | |
apiKey + method + timestamp + path, | |
secret, | |
) | |
const signature = CryptoJS.enc.Base64.stringify(hmac) | |
console.log(signature) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment