Creating APIs‎ > ‎Security‎ > ‎Authentication‎ > ‎

Retrieve an API Key

You can retrieve an API key from the command line using cURL. Use the apikey in an HTTP header named Authorization, in the format:

Authorization: CALiveAPICreator ff908cee433929b06ad8ecc122ff8fa1:1

The :1 added at the end of the API key is required.

For more information about cURL, see the cURL website.

  1. (If you do not know that a certain authentication provider is in use) Ask API Server what type of authentication information is required:
    curl https://eval.espressologic.com/rest/acme/myproject/v1/@login_info
    Substitute the proper URL to your project.
    The following response is expected:
    {
      "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
        }
      ]
    }
  2. Submit values for the parameters described in the response:
    curl -H "Content-type: application/json" --data-binary "{\"username\": \"jdoe\", \"password\": \"secret\"}" 
    -X POST https://eval.acme.com/rest/acme/myproject/v1/@authentication
    Substitute the proper values for the URL, the username, and the password.
    The following response is expected:
    {
      "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 API key is retrieved from the command line using cURL.