API authentication

Some Helix Search API endpoints need an authenticated connection. Authenticated connections are achieved using Token authentication or Bearer authentication.

Token authentication

Token authentication is an HTTP authentication system that uses an X-Auth-Token to authenticate the connection to Helix Search. The X-Auth-Token is generated by the server in response to a log in request. The generated X-Auth-Token is automatically added to the Helix Search config.properties file under the com.perforce.p4search.service.token configurable. See Index Auth Token in the Helix Search configuration section.

For example:

curl -H 'X-Auth-Token: <X-AUTH-TOKEN>' http://localhost:1601/api/v1.2/index/change/917503

Bearer authentication

Bearer authentication is an HTTP authentication system that uses a bearer token to authenticate the connection to Helix Search. The bearer token is generated by the server in response to a log in request. The bearer token is sent in the authorization header when you make an API request.

For example:

Obtain the bearer token by logging in to your Helix Search instance:

curl --location --request POST 'http://localhost:1601/api/v1/login' --header 'Content-Type: application/json'
--data-raw '{
  "user": "<p4user>",
  "passwd": "<p4password>",
  "ip": "<ipaddress>"
}'

Where <ipaddress> is the machine where the ticket will be generated.

Helix Search responds with the bearer token:

{
  "status": {
    "code": 200,
    "message": "OK"
  },
  "data": "<auth_token>"
}

To make an API request using the bearer token:

curl -X GET --location "http://localhost:1601/api/v1.2/install/extensions" -H "Authorization: Bearer <auth_token>" -H "Accept: application/json"