You use an HTTP bearer token to authenticate a vRealize Automation REST API consumer request .

About this task

A consumer request must specify the correct component registry service and resource. For example, the URL to obtain an HTTP bearer token must specify the identity service and token resource.

The HTTP bearer token expires in 24 hours by default. See Configure the Duration of an HTTP Bearer Token for information on how to set the duration.

For related information, see Syntax for Requesting an HTTP Bearer Token.

Prerequisites

  • Log in to vRealize Automation using the applicable credentials. For example, to assign a user to a role, log in as a tenant administrator.

  • Verify that the host name and fully qualified domain name of the vRealize Automation instance are available.

Procedure

Enter a curl command in the following format, replacing the variables with the correct values.

The variable $vRA used in this example represents the host name.domain name of the vRealize Automation server, for example, mycompany.mktg.mydomain.com.

curl --insecure -H "Accept: application/json" -H 'Content-Type: application/json'
--data '{"username":"usrname","password":"passwd","tenant":"tenantURLtoken"}' 
https://$vRA/identities/api/tokens

For example, enter the following command line:

curl --insecure -H "Accept: application/json" -H 'Content-Type: application/json' --data
'{"username":"TenantAdminUser @example.com","password":"password","tenant":"MYCOMPANY"}' 
https://vra.mycompany.com/identities/api/tokens

Results

The command returns a response header with a status code and, if your request is successful, an HTTP bearer token.

For example, the following sample output displays based on the command input:

HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Cache-Control: no-cache, no-store
  Pragma: no-cache
  Expires: Thur, 16 Jul 2015 23:59:59 GMT
  Content-Type: application/json;charset=UTF-8
  Content-Length: 324
  Date: Wed, 15 Jul 2015 13:04:50 GMT
{
 "expires":"2015-16-01T13:09:45.619Z",
 "id":"MTM5MTI1OTg5MDQwMzozNDQyZWMxZmQ5ZDliODUzMGFiMjp0ZW5hbnQ6cWV1c2VybmFtZTpmcml0ekBjb2tlLmNvb
 TplMDViNGU0NGM2ZWU0MWQ1OWEwMTNmZGExNTQwZjNlNGM3YTBlM2I5MDhlYWZjYjY1ZjhiODI2OTg4ODU3M2UwOTUwOWRk
 MjlmYWRjNWQ4NjJkOTk1YmE3MTg1MWZhOTc2MjEyYjYxZmU3YTVhZDcwNzM3ZTg3ZDNjNDk2ZDlmNA==",
 "tenant":"MYCOMPANY"
}

What to do next

Include the HTTP bearer token in your REST API service calls. You can store the token in a variable such as $AUTH and then use the variable in your requests.