Authenticate a third-party application with cURL

When you need to use the Vantage API and cURL to implement third-party authentication, you can use this example to help you.

cURL is an open source command-line interface (CLI) tool for data transfer that is often used in API development. You can use cURL to send your key name and key token via hypertext transfer protocol secure (HTTPS) and receive an authorization token in return.

  1. In the terminal, enter your command. For example:
    export KEY_NAME="AK12345"
    export KEY_TOKEN="abcdabcdabcd"  
    curl -sSL -D - "https://VANTAGE_URL/api/v1/keys/sign_in" 
    -H  "accept: */*" -H  "Content-Type: application/json" 
    -d "{\"key_name\":\"$KEY_NAME\",\"key_token\":\"$KEY_TOKEN\"}" 
    -o /dev/null
  2. Vantage returns a response that's similar to this partial example:
    HTTP/2 200 
    content-type: application/json; charset=utf-8
    content-length: 608
    authorization: Bearer abcabcbac
    [...]
  3. Pass the authorization string with your subsequent cURL requests. For example, you can request the list of alerts:
    curl -X GET "https://VANTAGE_URL/api/v1/alerts" 
    -H  "accept: */*" -H  "Authorization: Bearer abcabcbac"