Access the Armor API System via an API token - BASH
You can use the API tokenization feature (BASH) 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
When you create an API Key, you will generate a Secret Key. This key does not expire; you must securely store this key because Armor cannot retrieve this key for you.
If you lose the Secret Key, then you must delete the corresponding API Key in AMP. Afterwards, you must create a new API Key.
Armor cannot retrieve your Secret Key.
In the Armor Management Portal (AMP), in the left-side navigation, click Account.
Click Users.
Click API Keys.
Click the plus icon.
Enter a descriptive name, and then click Create Key.
Copy the Key ID and Secret Key.
Click Close.
The API Keys table will display a new entry.
Step 2: Authenticate into the Armor API system
To authenticate, you need to build a header with the following components:
Parameter | Description |
---|---|
app_id | Enter the Key ID generated from AMP. |
secret_key | Enter the Secret Key generated from AMP. |
request_path | |
http_method | Enter POST. |
timestamp | Enter a Unix time stamp within 5 minutes of the current time. |
nonce | Enter a unique ID.
|
For all v2 API's, the request body should be empty.
This uses a bash script with the assumption the following commands are installed uuidgen
, openssl
, base64
, and curl
The script is called with `./script "{apiKey}" "{secret}"
Review sample code for BASH:
#!/bin/bash
apikey=$1
printf "\n API KEY: $apikey"
secret=$2
# don't print secret
#printf "\n Secret: $secret"
authType="ARMOR-PSK"
printf "\n authType: $authType"
httpMethod="GET"
printf "\n Method: $httpMethod"
timestamp=$(date +%s)
printf "\n timestamp: $timestamp"
nonce=$(uuidgen)
printf "\n nonce: $nonce"
# Only the path portion of the url, no https, host, port, or query string values
requestPath="/core/avam"
requestBase="https://api.armor.com"
printf "\n requestPath: $requestPath"
# Empty string for GET
requestBody=""
requestData="${apikey}${httpMethod}${requestPath}${nonce}${timestamp}${requestBody}"
printf "\n requestData: $requestData"
# openssl needs the binary option
# set line wrapping to 0 to force base64 output on one line
signature=$(echo -n "$requestData" | openssl dgst -sha512 -hmac "$secret" -binary | base64 -w 0)
printf "\n Mac: $mac"
authHeaderValue="${authType} ${apikey}:${signature}:${nonce}:${timestamp}"
printf "\n authHeaderValue: $authHeaderValue \n"
echo '========================================================================'
echo ''
#Options are before the URL
curl -v \
--location \
-H "Authorization: ${authHeaderValue}" \
-H 'Content-Type: application/json' \
--request $httpMethod \
"${requestBase}${requestPath}"
Step 3: Make an API Call
To learn about the different calls that you can make, see Armor API Guide.
Related Documentation
To learn about the different calls that you can make, see Armor API Guide.
To learn how to create an API key or to learn a different way to access the Armor API system, see Pre-Shared Key Authentication Method.