๐ PRO Topic - Integrating APIs with SHA-256 Signatures in N8N
Using no-code tools like N8N is great for automation, but when you need to connect with government services, financial platforms like Binance, or cloud providers like Cloudinary, things get tricky. Some of APIs require SHA-256 signatures to secure requests, which means you need to generate a unique signature for every request. This process might sound complicated, but itโs actually straightforward when broken down. ๐ค Why Use Signatures Instead of Just an API Key? Some services donโt accept just an API key for security reasons. Instead, they require a hashed signature to: โ
Prevent tampering & replay attacks โ
Ensure data integrityโthe server verifies the signature before processing โ
Use a secret key to sign specific request parameters โ๏ธ How the Authentication Process Works in N8N Hereโs the basic setup to integrate APIs that require SHA-256 authentication: 1๏ธโฃ Set all required variables in a Set node (API key, timestamp, request parameters). โ ๏ธ Use Fixed Timestamp โ Ensures signature matches request 2๏ธโฃ Generate the signature using a Crypto node (method varies by service). 3๏ธโฃ Send the request using an HTTP Request node, including the signature and required parameters. ๐ API-Specific Logic ๐ฉ๏ธ Cloudinary (SHA-256 Hash - Hex) ๐น Signature logic: โข Uses SHA-256 hashing (not HMAC) โข Concatenates parameters + secret โ Hashes them in Hex โข The secret is appended at the end instead of being used as a key ๐ Binance (HMAC SHA-256 - Hex) ๐น Signature logic: โข Uses HMAC SHA-256 with secret key as the key โข Takes request parameters โ HMAC Hash โ Converts to Hex โข Requires a recvWindow (e.g., 5000ms) to prevent expired requests ๐ฐ OKX (HMAC SHA-256 - Base64) ๐น Signature logic: โข Uses HMAC SHA-256 but encodes in Base64 โข String format: timestamp + method + path + body โข Secret key is used as an HMAC key ๐พ Templates for all services attached below! Try it out and let me know if you have questions! ๐