Authentication¶
Every method of the API requires an access token. You request it with your credentials and send it in the
Authorization header of each request.
URL¶
POST https://ocelot.servientrega.us/connect/token
POST https://ocelotkiwi.azurewebsites.net/connect/token
Parameters¶
Send them as a form (Content-Type: application/x-www-form-urlencoded), not as JSON.
| Name | Required | Value |
|---|---|---|
client_id |
Yes | Provided by Servientrega USA |
client_secret |
Yes | Provided by Servientrega USA |
grant_type |
Yes | Always password |
username |
Yes | Your Kiwi username (the e-mail assigned to you) |
password |
Yes | Your Kiwi password |
Request example¶
curl -X POST "https://ocelot.servientrega.us/connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "client_id=<YOUR_CLIENT_ID>" \
--data-urlencode "client_secret=<YOUR_CLIENT_SECRET>" \
--data-urlencode "grant_type=password" \
--data-urlencode "username=<YOUR_USERNAME>" \
--data-urlencode "password=<YOUR_PASSWORD>"
curl -X POST "https://ocelotkiwi.azurewebsites.net/connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "client_id=<YOUR_CLIENT_ID>" \
--data-urlencode "client_secret=<YOUR_CLIENT_SECRET>" \
--data-urlencode "grant_type=password" \
--data-urlencode "username=<YOUR_USERNAME>" \
--data-urlencode "password=<YOUR_PASSWORD>"
Response example¶
{
"access_token": "<ACCESS_TOKEN>",
"expires_in": 14400,
"token_type": "Bearer"
}
Using the token¶
Send the token in the Authorization header of every request:
Authorization: Bearer <ACCESS_TOKEN>
Notes¶
- Test and Production have different credentials. To request Test credentials, write to developers@servientrega.us.
- The token is valid for
expires_inseconds (currently 14400 seconds, 4 hours). Read that value from the response instead of fixing the time in your code: it may change. - When the token expires, the API answers
401 Unauthorized. Request a new token and repeat the request. - Reuse the same token while it is valid. Do not request a new token for every call.
- For security reasons, credentials expire if they are not used for some time. If your credentials stop working, write to developers@servientrega.us.
- Keep your credentials and tokens private. Do not include them in web pages, mobile apps or code repositories.