Docs‎ > ‎CA Live API Creator‎ > ‎Security‎ > ‎Authentication‎ > ‎

Using the command line

In some cases, you may need to retrieve an API key from the command line. This can easily be done using curl.

First, ask the API Server what type of authentication information is required (you can of course skip this if you know that a certain authentication provider is in use):

curl https://eval.espressologic.com/rest/acme/myproject/v1/@login_info

You'll need to substitute the proper URL to your project.

The response should be something like:

{
  "links": [
  ],
  "fields": [
    {
      "name": "username",
      "display": "Username",
      "description": "Enter your username",
      "helpURL": null,
      "type": "text",
      "length": 30
    },
    {
      "name": "password",
      "display": "Password",
      "description": "Enter your password",
      "helpURL": null,
      "type": "password",
      "length": 30
    }
  ]
}

You then submit values for the parameters described in that last response:

curl -H "Content-type: application/json" --data-binary "{\"username\": \"jdoe\", \"password\": \"secret\"}" 
-X POST https://eval.acme.com/rest/acme/myproject/v1/@authentication

Once again, you'll need to substitute proper values for the URL, the username and the password.
The response should look like:

{
  "apikey": "ff908cee433929b06ad8ecc122ff8fa1",
  "expiration": "2014-07-22T12:00:42.398Z",
  "lastLoginTs": "2014-07-21T02:00:04.000Z",
  "lastLoginIP": "12.34.56.78",
  "email": "jdoe@acme.com"
}

The apikey is the critical piece of information. You will typically use it in an HTTP header named Authorization (an unfortunate name, but that's the convention), in the format:

Authorization: CALiveAPICreator ff908cee433929b06ad8ecc122ff8fa1:1

Note the :1 added at the end of the API key -- it is required.