Authenticate
Gets a short-lived access token, which is required in the header of most subsequent API requests. A client can obtain an access token by presenting a valid login name and API key.
The access token is used to communicate to the REST API that the bearer of the token has been authorized to access the API and perform specific actions specified by the scope that was granted during authorization.
The login must be URL encoded. For example, alice@devops
must be encoded as alice%40devops
.
host/
. For example, the host webserver
would log in as host/webserver
, and would be encoded as host%2Fwebserver
.
Access tokens expire after 8 minutes. You need to obtain a new token after it expires.
Example with curl
In the following example, a host with ID some/application
authenticates to Conjur at https://eval.conjur.org
where account is set to myorg
and the API key is apiKeyGoesHere
using the authn
authenticator:
curl --header "Accept-Encoding: base64" --data apiKeyGoesHere https://eval.conjur.org/authn/myorg/host%2Fsome%2Fapplication/authenticate
URI
|
URI Parameters
Parameter |
Type |
Mandatory |
Description |
---|---|---|---|
authenticator |
String |
Yes |
Authentication method Example: |
account |
String |
Yes |
Organization account name. Example: |
login |
String |
Yes |
Login name of the client. For users, it’s the user id. For hosts, the login name is Example: |
Example URI
|
Request
Header |
|
||
Body |
The request body is the API key. For example:
|
Response
Code |
Description |
---|---|
200 |
The response body is the access token |
401 |
The request lacks valid authentication credentials |
Response 200 example
Header
|
Body
|
If you use the
|
How to use the access token
For API usage, the access token is ordinarily passed as an HTTP Authorization “Token” header.
|
The access token can be used for Conjur API access like this:
|
If you did not encode the access token by passing the Take the response from the authentication request and base64-encode it, stripping out newlines:
|