REST API for retrieving authentication token

You use the POST operation on the api/get_token element to request your unique token that is required to authenticate the REST API requests.

Important: This REST API call does not work when single sign-on authentication is enabled. To view the token, log in to License Metric Tool, hover over the User icon User icon, and click Profile. Then, click Show token.

Resource URL

https://server_url:server_port/api/get_token

Resource information

Table 1. Resource information
Operation details Description
Purpose Returns the authentication token
HTTP method POST
Request headers
Accept-Language (optional)
  • Use: Used to negotiate the language of the response. If this header is not specified, the content is returned in the server language.
  • Values: en-US (only English is supported)
Request payload
{
    "user" : "username",
    "password" : "password"
}
Request Content-Type
  • application/json
Response headers
Content-Type
  • Use: Specifies the content type of the response.
  • Values: application/json
Content-Language
  • Use: Specifies the language of the response content. If this header is not specified, the content is returned in the server language.
  • Values: en-US, …
Response payload Token element
Response Content-Type
  • application/json
Normal HTTP response codes
  • 200 – OK
Error HTTP response codes
  • 500 – “Bad Request” if a query parameter contains errors or is missing

Message body includes an error message with details.

Example conversation

The following example uses cURL command-line tool for negotiating API requests. To obtain the token, use the following POST request.

Request
curl -k -X POST -H "Content-Type: application/json" -H "Accept: application/json" 
-d {\"user\":\"username\",\"password\":\"userpassword\"} https://server_url:server_port/api/get_token
Where:
-k
Use this option to disable License Metric Tool certificate verification procedure.
-H
Specifies the header of the request.
-X
Specifies the type of the HTTP request.
-d
Contains the JSON payload for authentication.
username
The username for authentication.
userpassword
The password for the specified user.
server_url
The server address where the License Metric Tool is hosted.
server_port
The port number on which the License Metric Tool service is running.
Response
{
"token":"<token>"
}