I'm trying to create a reusable API authentication mechanism in Retool. Here's what I need to accomplish:
Current Implementation:
I have a JavaScript function that:
- Generates a timestamp in Asia/Shanghai timezone
- Creates a signature string with multiple parameters (app_key, biz_content, charset, etc.)
- Performs AES encryption (CBC mode, PKCS7 padding) on the signature string
- Uses the encrypted signature to make API calls
Code example:
async function sign(para_biz_content, para_methord) {
const timestamp = moment().zone("Asia/Shanghai").format("x");
const SignString2 = "app_key=xxx" +
"&biz_content=" + para_biz_content +
"&charset=UTF-8" +
"&interface_method=" + para_methord +
// ... other parameters ...
"×tamp=" + timestamp;
const encrypted = CryptoJS.AES.encrypt(SignString2, key, {
keySize: 128,
iv: iv1,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
// Use encrypted signature in API calls
}
How can I set up the authentication in the REST API Resource configuration?

