Users must authenticate successfully before any further API calls can be made.
To demonstrate, here is an example of how to authenticate to obtain a token and use that token to retrieve port details.
Make the following PUT request to authenticate a with a username and password.
curl -X PUT 'https://api.consoleconnect.com/api/auth/token' \
-H 'Content-Type: application/json' \
--data-raw '{
"email": "user@example.com",
"password": "Password1"
}'
The response body will include user details, including a “token” element, which must be passed as the value for a “portal-token” header in each subsequent API request.
{
"..."
"token": "123456789012345678901234567890123456789012345678901234567890abcd",
"..."
}
Include the token in the "portal-token" header to make an authenticated request to api/company/exampleCo/ports
,
which will respond with a list of ports for the company "exampleCo".
curl -X GET https://api.test.consoleconnect.com/api/company/exampleCo/ports \
-H "portal-token: 123456789012345678901234567890123456789012345678901234567890abcd"
User authentication (login) must occur before any further API calls can be made. The token from the response must be passed as the value for a “portal-token” header in each subsequent API request.
OK
Unauthorized
{- "email": "user@example.com",
- "password": "Password1"
}
{- "token": "e4e0c6e2c5e73963e60a1132948e1c7f84f1f4cdd04a254e9215ab314b48e26e",
- "id": "58980a25a77b4d7bf459d100",
- "username": "stella",
- "name": "Stella",
- "email": "stella@example.com"
}