Authentication
In Intel Exchange, you can manage user access and feature permissions by defining Open API roles and generating credentials to control access.
Generate API credentials
Generate the API credentials to get the access ID, secret key, and base URL of your Intel Exchange application. For more information, see Generate Open API Credentials.
Generate API Request Parameters
To authenticate the API requests made to the Intel Exchange application, you must include the following parameters in the query of each API request:
-
Access ID: Indicates the access ID of your Intel Exchange open API credentials.
-
Expires: Indicates the validity of the signature parameter. The signature becomes invalid if not used within the specified expiry duration. You can set the expiry for a maximum of 30 seconds.
-
Signature: A combination of the access ID, secret key, and expires parameters to authenticate API requests. The signature is hashed using the HMAC-SHA1 algorithm, and then encoded using the Base64 scheme.
Use the following Postman script in the pre-request script to generate the Expires and Signature parameters in Postman:
var accessid = pm.environment.get("accessid");
var secret_key = pm.environment.get("secretkey");
/*
-generating epochtime
-epochtime is being send in expires parameter of params
-sign is generated and then passed for generating signature
/
pm.environment.set("unixtimestamp", Math.round(Date.now() / 1000));
var expires = pm.environment.get("unixtimestamp") + 20;
pm.environment.set('UTC Timezone', new Date().toISOString());
pm.environment.set("expires", expires);
var to_sign = accessid + "\n" + expires;
/
Generate Signature for Authentication
-Key based hashing is done using HMAC-SHA1 Algorithm
-This is then converted into base64
-Finally the generated signature is URL Encoded so as to make all the special characters URL Safes
*/
var hash = CryptoJS.HmacSHA1(to_sign, secret_key);
var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);
hashInBase64 = hashInBase64.replaceAll("+", "+");
hashInBase64 = hashInBase64.replaceAll("/", "/");
hashInBase64 = hashInBase64.replaceAll("=", "=");
pm.environment.set("signature", hashInBase64);
pm.request.url.query.add('AccessID=' + accessid);
pm.request.url.query.add('Signature=' + hashInBase64);
pm.request.url.query.add('Expires=' + expires);View-only example — running live API calls requires a role with snippet testing access.
Use the following Python script to generate the Expires and Signature parameters to use in Python integrations:
import time
import hmac
import hashlib
import base64
import urllib.parse
import requests
# Credentials to access CTIX OpenAPI
CTIX_SERVER_URL = "https://sample.domain.com/ctixapi"
CTIX_ACCESS_ID = "<enter access id>"
CTIX_SECRET_KEY = "<enter secret key>"
def create_signature(secret_key, message):
hashed = hmac.new(secret_key.encode("utf-8"), message.encode("utf-8"), hashlib.sha1)
b64_signature = base64.b64encode(hashed.digest())
return urllib.parse.quote_plus(b64_signature)
def make_request(method, url, headers, query_params, data=None):
print(f"-- Request --------------------------------------------------------")
print(f"URL: { url }")
print(f"Method: { method }")
print(f"Headers: { headers }")
print(f"Query Params: { query_params }")
print(f"Payload: { data }")
response = requests.request(
method, url, headers=headers, data=data, params=query_params
)
print(f" -- Response ----------------------------------------------------")
print(f" Status Code: { response.status_code }")
print(f" Response: { response.text }")
return response
# Get current timestamp in seconds (equivalent to JavaScript's Date.now() / 1000)
unix_timestamp = int(time.time())
expires = unix_timestamp + 25
to_sign = f"{CTIX_ACCESS_ID}\n{expires}"
signature = create_signature(CTIX_SECRET_KEY, to_sign)
# Add AccessID, Signature and Expires to the URL parameters
query_params = {"AccessID": CTIX_ACCESS_ID, "Signature": signature, "Expires": expires}
# perform a PING request
url = f"{ CTIX_SERVER_URL }/ping/"
make_request("GET", url, headers={}, query_params=query_params)View-only example — running live API calls requires a role with snippet testing access.
Define Open API rate limits
Define rate limits for your APIs to ensure that all your API users are getting a fair share of the application resources. This also ensures that APIs and servers run smoothly and efficiently.
For more information, see Define Rate Limits for Open API in Intel Exchange.