Skip to content

Instantly share code, notes, and snippets.

@edunuzzi
Created June 24, 2020 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edunuzzi/6fe33ff26a60a6a398fa2e2e855c30d6 to your computer and use it in GitHub Desktop.
Save edunuzzi/6fe33ff26a60a6a398fa2e2e855c30d6 to your computer and use it in GitHub Desktop.
Um pequeno exemplo de autenticação na API da Swipe utilizando NodeJS
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