Skip to main content

Programmatically apply a License Code

License codes can be applied to an Iguana instance manually in IguanaX License Settings. However, there are two possible methods to programmatically apply a license code to an Iguana instance:

Method 1: On the command line, write the license code to the IguanaLicense File

Windows

The IguanaLicense file is found in your Iguana Working Directory.

Use the following command with your appropriate working directory:

echo $IguanaLicenseCode > C:\ProgramData\IguanaX\config\other\IguanaLicense;   

Linux

The IguanaLicense file is found in your Iguana Working Directory.

Use the following command with your appropriate working directory:

echo $IguanaLicenseCode > /home/iguanauser/.IguanaX/config/other/IguanaLicense;   

Method 2: Use the IguanaX API to apply the license code to the target Iguana instance

STEP 1: Call GET /session/login to login and get a session cookie to authenticate IguanaX API requests.

Method: GET /session/login

To call the IguanaX APIs you must first login and get a session cookie from the response header to authenticate your subsequent requests.

Use your Iguana instance IP address and port: https://127.0.0.1:7654

Parameters:

  • username: Your IguanaX instance username string

  • password: Your IguanaX instance password string

Example curl command calling the /session/login API and parsing to retrieve Iguana session cookie the response header Set-Cookie to authenticate the next API call:

IguanaCookie='curl -i -k -X GET "http://127.0.0.1:7654/session/login?username=<user>&password=<pass>" | grep -i 'Set-Cookie: ' | awk '{print $2}' | sed 's/;$//''   

Should look similar to: IguanaSession-jYQGeQWk97ylKuP8AmEiad=z7WR4Xwzk51hXMP2e3WeZa

Response Header:

Content-Length: 128   
Set-Cookie: IguanaSession-jYQGeQWk97ylKuP8AmEiad=z7WR4Xwzk51hXMP2e3WeZa; path=/; HttpOnly; SameSite=Strict

STEP 2: Call POST /license/set to apply the license code to the Iguana instance

Method: POST /license/set

This API method applies the registered license code to the Iguana instance and returns a JSON object containing the request success or failure. To authenticate, the obtained Cookie is provided in the header of the request.

Parameters:

Example curl command calling the /license/set API to apply the license code and activate the Iguana instance:

IguanaID='curl -k --header "Cookie: $IguanaCookie" -X POST "http://127.0.0.1:7654/license/set?license=<LicenseCode>"   

Response:

{   
"data": {},
"success": true
}