Overview
You can use the API tokenization feature in the Armor Management Portal (AMP) to create an API key. This key will help you log into the Armor API system.
Step 1: Create an API key
Insert excerpt ESLP:Create an API (snippet) ESLP:Create an API (snippet) nopanel true
Step 2: Authenticate into the Armor API system
- In your Postman application, create a new GET request with the following endpoint: https://api.armor.com/roles
- Click Headers.
- Under Key, select Authorization.
- In Value, enter {{hmacAuthHeader}}.
- Under Key, select Content-Type.
- In Value, enter application/json.
- Click Pre-request Script.
- Enter the script below with the following updated parameters:
...
Code Block |
---|
function getPath(url) { var pathRegex = /.+?\:\/\/.+?(\/.+?)(?:#|\?|$)/; var result = url.match(pathRegex); return result && result.length > 1 ? result[1] : ''; } function getQueryString(url) { var arrSplit = url.split('?'); return arrSplit.length > 1 ? url.substring(url.indexOf('?')+1) : ''; } function getAuthHeader(httpMethod, requestUrl, requestBody) { *var APP_ID = '<use the api key id>';* *var SECRET_KEY = '<use the secret key>';* var AUTH_TYPE = 'ARMOR-PSK'; var requestPath = getPath(requestUrl).replace('https', 'http'); var queryString = getQueryString(requestUrl); if (httpMethod == 'GET' || !requestBody) { requestBody = ''; } else { requestBody = requestBody.toString(); requestBody = CryptoJS.enc.Base64.stringify(CryptoJS.SHA512(requestBody)); } var timestamp = Math.round(new Date().getTime() / 1000); var nonce = timestamp; var requestData = [APP_ID, httpMethod, requestPath, nonce, timestamp, requestBody].join(""); var mac = CryptoJS.HmacSHA512(requestData, SECRET_KEY); var signature = CryptoJS.enc.Base64.stringify(mac); var authHeader = AUTH_TYPE + ' ' + APP_ID + ':' + signature + ':' + nonce + ':' + timestamp; return authHeader; } postman.setEnvironmentVariable('hmacAuthHeader', getAuthHeader(request['method'], request['url'], request['data'])); |
Step 3: Make an API Call
To learn about the different calls that you can make, see Armor API Guide.
...