Follow

Authenticate Against the Cloud Insight API | How To

Description

The following article describes how to authenticate against the Alert Logic® Cloud Insight™ API. Utilize this information if you are looking to integrate Cloud Insight into your own products and/or environments.

Solution

  1. Authenticate against the Cloud Insight API with a POST request using your Cloud Insight username and password.

    An example CURL command is below. Please note that customers provisioned in our UK data center will need to use 'https://api.cloudinsight.alertlogic.co.uk'.

    curl -X POST -u username:password
    https://api.cloudinsight.alertlogic.com/aims/v1/authenticate

  2. A successful response will give an HTTP 200 response code. You can optionally pipe to jq by appending ' | jq .' to the end of the command to receive a formatted response as follows:

    curl -v -X POST -u username:password
    https://api.cloudinsight.alertlogic.com/aims/v1/authenticate | jq .

    {
    "authentication": {
    "id": "715A4EC0-9833-4D6E-9C03-A537E3F98D23",
    "account_id": "Bob Dobalina",
    "email": "bob@company.com"
    "active": true,
    "locked": false,
    "version": 1,
    "created": {
    "at": 1530183768,
    "by": "System"
    },
    "modified": {
    "at": 1430183768,
    "by": "System"
    }
    },
    "account": {
    "id": "12345678",
    "name": "Company Name",
    "active": true,
    "version": 1,
    "accessible_locations": ["insight-us-virginia"],
    "created": {
    "by": "System",
    "at": 1436482061
    },
    },
    "token":
    "eyJ0eXAiOiJKV1QiLCJhbGciOiJlUzl1NiJ9.eyJ1c2VyljoiMDAwMDAwMDAiLCJhY2NvdW50ljoiMDAwMDAwMDAiLCJleHBpcmF0aW9uljoxNDMwMTg0Nzc2LCJyXW5ld19jb3VudGRvd24iOjl0fQ==.QKRHma5zAOdhU50ZE4ryPxVpvKt0A0gbjY62xHCWm8s=",
    "token_expiration": 1434042731
    }

  3. Take note of the token value, as you will need to provide this in future requests to the Cloud Insight API. The token expiration is listed in epoch time below the token.

    NOTE: Possible HTTP Response Codes include:

    Field Description
    password_expired 400 Bad Request - User tried to log in with an expired password
    unauthorized 401 Unauthorized - The credentials passed could not be authenticated
  4. All subsequent requests should specify the 'x-aims-auth-token' value in the header. Variables are represented with a dollar sign:

    curl "https://api.cloudinsight.alertlogic.com/assets/v1/$account_id/environments/$environment_id/assets" -H "x-aims-auth-token: $token"

    A completed example is below:

    curl "https://api.cloudinsight.alertlogic.com/assets/v1/12345678/environments/F8FDBCBE-2CE9-47C7-97EF-31CE1D041A4D/assets" -H "x-aims-auth-token: eyJ0eXAiOiJKV1QiLCJhbGciOiJlUzl1NiJ9.eyJ1c2VyljoiMDAwMDAwMDAiLCJhY2NvdW50ljoiMDAwMDAwMDAiLCJleHBpcmF0aW9uljoxNDMwMTg0Nzc2LCJyXW5ld19jb3VudGRvd24iOjl0fQ==.QKRHma5zAOdhU50ZE4ryPxVpvKt0A0gbjY62xHCWm8s="
Was this article helpful?
4 out of 4 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.