### Generate Security Token for Constellix API (JavaScript) Source: https://api-docs.constellix.com/index This script generates a security token required for authenticating with the Constellix API. It takes API and Secret keys from environment variables, calculates an HMAC-SHA1 hash based on the current timestamp and the secret key, and combines them into a single token string. This token is then set as an environment variable for use in subsequent API requests. ```javascript var apiKey = postman.getEnvironmentVariable("apiKey"); var secretKey = postman.getEnvironmentVariable("secretKey"); function epochTime() { return new Date().getTime() + ''; } postman.clearEnvironmentVariable("x-cns-security-token"); var time = epochTime(); var hmac = CryptoJS.HmacSHA1( time, secretKey ).toString( CryptoJS.enc.Base64 ); var token = apiKey + ":" + hmac + ":" + time; postman.setEnvironmentVariable( 'x-cns-security-token', token ); ``` -------------------------------- ### Constellix DNS API Authentication Source: https://api-docs.constellix.com/index Details on how to authenticate requests to the Constellix DNS API using API keys, Secret Keys, and HMAC-SHA1. ```APIDOC ## Authentication and Security Headers Authentication with the Constellix API is performed using the API and Secret keys, provided on a per-user basis. ### Security Headers - `x-cnsdns-apiKey`: Your Constellix API key. - `x-cnsdns-requestDate`: The timestamp of the request in epoch milliseconds. - `x-cnsdns-hmac`: The Base64 encoded HMAC-SHA1 hash of the request timestamp and your Secret Key. Alternatively, these headers can be combined into a single header: - `x-cns-security-token`: Concatenation of `apiKey:hmac:requestDate`. ### Example Security Token Generation (Postman) ```javascript var apiKey = postman.getEnvironmentVariable("apiKey"); var secretKey = postman.getEnvironmentVariable("secretKey"); function epochTime() { return new Date().getTime() + ''; } postman.clearEnvironmentVariable("x-cns-security-token"); var time = epochTime(); var hmac = CryptoJS.HmacSHA1( time, secretKey ).toString( CryptoJS.enc.Base64 ); var token = apiKey + ":" + hmac + ":" + time; postman.setEnvironmentVariable( 'x-cns-security-token', token ); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.