After generating the tokens, copy the token and add it to the appropriate REST API request as needed to authenticate the request.
Usage Scenario:
For example, if you have a script that performs some operation on the database, the script must be authenticated for valid authorization. To enable the script for authentication, perform the following:
Generate the token for the specific database from the user console.
Copy and paste the generated token to the credential check-in and checkout REST API requests as described in the following sample:
Sample REST API for Credential Check Out Using Tokens
Request:
curl --insecure -X POST -H "Authorization:Token token=<API_Token>" -H "Cache-Control: no-cache" -H "Content-Type:application/json" -d '{ "Request": { "type": "PasswordCheckout", "runHost": "<Specify the target resource for which you want the credentials.>", "reason": "<Reason for credential checkout.>", "duration" : "<Specify the credential expiry duration in minutes. >", "emailid": "<Specify your email address to get notifications. >" } }'"https://<PAM_SERVER>/rest/cmdctrl/Request"
Response:
{
"CheckOut": {
"Request": {
"id": "<Request Id>"
},
"account": "<username>",
"passwd": "<password>"
},
"message": "OK",
"status": 200,
"vrm": "3.5.0"
}Sample REST API for Credential Check In Using Tokens
Request:
curl --insecure -X PUT -H "Authorization:Token token=<API_Token>" -H "Cache-Control: no-cache" -H "Content-Type:application/json" -d '{ "Request": { "type": "PasswordCheckin", "runHost": "<Specify the target resource whose credentials must be checked in.>" } }'"https://<PAM_SERVER>/rest/cmdctrl/Request/<Request Id>"
Response:
{
"message": "OK",
"status": 200,
"vrm": "3.5.0"
}Include the credential check out and the check in REST API requests with the token in the script.
The database authentication credentials are received as a response of the REST API request, which must be used by the script for logging in to the target application.
Ensure that you call the REST API for credential check out and check in at the beginning and end of the script respectively.