Web tokens enable two parties to transfer information securely. Applications Manager enables you to configure web tokens globally which can be used by the monitors for data collection.
Note: The Web Token authentication is currently supported only for the REST API and REST API Sequence monitors.
Navigate to Settings → Discovery & Data Collection → Credential Settings → Web Token → Add New Web Token.
Add Web Token: Specify token details.
Token Request Configuration: Specify the configuration for requesting the token.
username=adminuname&password=adminpasswd
<credentials>
<username>adminuname</username>
<password>adminpasswd</password>
</credentials>
{
"username": "adminuname",
"password": "adminpasswd"
}
Token Request Extraction: The token value in the response is extracted and can be further used to customize request parameters, headers, and more for other monitor types where authentication is needed in the request URI.
Note: Values present in response headers can also be read.
Token Configuration for Monitor DataCollection:
The web token value is substituted in place of ${WebToken}
in the value field.
Authorization: Bearer ${WebToken}
token=${WebToken}
Given below are the various response formats you can expect from token endpoint.
Note: Token response path is the path to extract the token and Response refers to the response from the token Endpoint URL.
{ "access_token":"XXXXXXX", "token_type":"bearer", "expires_in":4289, "issued":"Mon, 20 Jun 2021 09:39:44 GMT", "list":[ { "tokenName":"StudentAuth", "tokenValue":"3q898sejhg" }, { "tokenName":"ProfAuth", "tokenValue":"$97q3ekh" }, { "tokenName":"StaffAuth", "tokenValue":"93&3jhiudz" } ] }
Following are few example JSON response paths and their respective values extracted for the above sample JSON data:
Response Path | Web Token Value |
---|---|
access_token | XXXXXXX |
token_type | bearer |
list |
"list":[ { "tokenName":"StudentAuth", "tokenValue":"3q898sejhg" }, { "tokenName":"ProfAuth", "tokenValue":"$97q3ekh" }, { "tokenName":"StaffAuth", "tokenValue":"93&3jhiudz" } ] |
list[1].tokenValue | 3q898sejhg |
list[0].tokenName | StudentAuth |
list[2].tokenValue | 3jhiudz |
<petstore> <animals> <pet id="1"> <type>Dog</type> <name no="1">Richie</name> <age>8</age> </pet> <pet id="2"> <type>Cat</type> <name no="2">Sky</name> <age>4</age> </pet> </animals> <birds> <bird id="1"> <name no="3">Snow</name> <age>5</age> </bird> <bird id="2"> <name no="4">Ray</name> <age>7</age> </bird> </birds> </petstore>
Following are few example XPATH expressions and results for the above sample xml data:
XPath Expression | Description | Result |
---|---|---|
/ | Select the document node | The output will be same as the xml content given as input |
/petstore/animals/pet | Select all the 'pet' elements, which are the direct children of 'animals' node |
<pet id="1"> <type>Dog</type> <name no="1">Richie</name> <age>8</age> </pet> <pet id="2"> <type>Cat</type> <name no="2">Sky</name> <age>4</age> </pet> |
//name[@no] | Select all the 'name' elements with 'no' attribute |
<name no="1">Richie</name> <name no="2">Sky</name> <name no="3">Snow</name> <name no="4">Ray</name> |
/petstore//bird[last()] | Select the last bird element |
<bird id="2"> <name no="4">Ray</name> <age>7</age> </bird> |
sum(//age) | Select the sum of age element values | 24 |
string-length(//pet[1]/name) | Select the length of the first 'pet' element's name value | 6 |
//pet[1]/name/text() | Select the textual value of first 'pet' element's name | Richie |
count(/petstore//pet) | Select the count of 'pet' elements | 2 |
The entire response is considered as the token.
The given header name in the Token Response Path is the actual token value.
Example:
Response Path: tokenvalue
tokenvalue: ebfb7ff0-b2f6-41c8-bef3-4fba17be410c
Note: If two headers of the same name are present, then the last one is considered.