Getting a token

×

Status message

New Feature: Guest Login function added to facilitate site exploration without registering. Try it out!

To access Adama you need to have an account at Araport.

Define the following variables in your shell, to avoid typing the Araport and Adama urls every time:

export ARAPORT=https://api.araport.org
export ADAMA=$ARAPORT/community/v0.3
export USERNAME=<your username at araport.org>
export PASSWORD=<your password>

Getting your API keys

In order to authenticate and interact with the API, you will need to get a set of API keys. This is a one-time action. If you already have your API keys, skip to the next section. If not, you can create your keys using the Clients service.

curl -Lk -X POST \
     -u "$USERNAME:$PASSWORD"  \
     -d "clientName=my_cli_app" \
     $ARAPORT/clients/v2

The response should look like (edited for brevity):

{
    "message": "Client created successfully.",
    "result": {
        ...
        "consumerKey": "gTgpCecqtOc6Ao3GmZ_FecVSSV8a",
        "consumerSecret": "hZ_z3f4Hf3CcgvGoMix0aksN4BOD6",
        ...
    },
    "status": "success",
    ...
}

Take note of the fields consumerKey and consumerSecret.

Obtaining an authentication token

Using the API username, password, and keys from above, you can obtain an authentication token from the OAuth service (substitute consumerKey and consumerSecret for the values returned before):

curl -Lk -X POST \
     -u "<consumerKey>:<consumerSecret>"  \
     -d "grant_type=password" \
     -d "username=$USERNAME" \
     -d "password=$PASSWORD" \
     -d "scope=PRODUCTION" \
     $ARAPORT/token

The response should look like:

{
    "access_token": "de32225c235cf47b9965997270a1496c",
    "expires_in": 14266,
    "refresh_token": "196f45495f6d9d0bc15416f7c55c39a",
    "token_type": "bearer"
}

The field access_token contains the token that you will use to access the Adama API in every curl statement. Save it to a variable with:

export TOKEN=de32225c235cf47b9965997270a1496c