Get Access Token

Token allows you to access to Smart Livraison APIs

Smart Livraison APIs use the OAuth 2.0 protocol for authentication and authorization.

To begin, obtain OAuth 2.0 client credentials from the application creation. Then your client application requests an access token from the Smart Livraison Authorization Server, extracts a token from the response, and sends the token to the Smart Livraison API that you want to access.

post
Get Access Token

https://api.smartlivraison.com/oauth/token
Make a POST request with Body JSON
Request
Response
Request
Headers
Content-Type
required
string
Content-Type must be application/json
Body Parameters
client_id
required
string
CLIENT_ID is generated by application creation
client_secret
required
string
CLIENT_SECRET is generated by application creation
scope
optional
string
* is only value you can use
grant_type
required
string
client_credentials is only value you can use
Response
200: OK
When your have correct credentials
{
"token_type": "Bearer",
"expires_in": 300,
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIzIiwianRpIjoiODkxMjYyZDcwZmIyMzkxNDdkYjM0NDI3MjFjNmFjYWZkMjVlNmNkMDI1N2JmYWM3NDdiMWIzODhhZWUyMmRhMDAwYzI0MjI5MGYyMWM0YzgiLCJpYXQiOjE1OTM5ODkyNDEsIm5iZiI6MTU5Mzk4OTI0MSwiZXhwIjoxNTkzOTg5NTQxLCJzdWIiOiIiLCJzY29wZXMiOlsiKiJdfQ.rt94SizSdTMG_U7KFccR68UGRP2GWmA5iHam9H0msDD-pNfXFFa-ohVVIrXz_zct7XrRnHgqoeXx7du_3XX6MoSK5gtKNFJaFBU6A2FUceQ65iV_syG1Vg0eHk37bGn0PdwXQXJKopKF0eHhJHYAEQlMe6cEABDhvEibMmAIkkkOB5XY8Tx5rQ3rEFb2iTHBMW2GKh-YOHoo2fQqR1NW1aART98kZtie9Tm5cwx9C3_82j84PpPz5XBTo-z_lScq0w8z4bbSFiy69g893ShDXuEwHdQMSV2SxIb0oOMVeNuUvC6KWRWjj4H9_KJZvutMlFyzXIIPuiAjGL1RAbEtxu7ADLjNQ5mg3DLYFS2cWD7Q2hXazeIJKlZLJx3rxGorLkt-MZM4gQenHjVFAleERbqmveRo2w_A9n9F0r6Ia4JNglI2eOvQj1xjxYmze4Du2CaQWPlr7ovUX6KpHPt0SqX3Ws0PUUO5n_wsdhJYgQICqpktv_G8uEv8GEcMZ8xw0sTkKWdFgkr2OXyzpjtrdLQPS6Rvd_KcxQ696lB7Qu7-ePbnuO-PVWHr1aJqBcn5AhxbahUWAYVtcUX5QMYTwsyB1lfBL8eEva_ZhOJEVN5yarYygH7rHx3DpqhPzo5FLrdz2uyyt6nB6CLzQge70xhZdkILr6r2ooPLoC49Abs"
}
401: Unauthorized
When you have bad credentials
{
"error": "invalid_client",
"error_description": "Client authentication failed",
"message": "Client authentication failed"
}
HTTP
CURL
Java - OkHttp
PHP - cURL
Python - http.client
HTTP
POST /oauth/token HTTP/1.1
Host: api.smartlivraison.com
Content-Type: application/json
{
"grant_type":"client_credentials",
"client_id":"3",
"client_secret":"yMfQdO3eSVCWO8QREQUF8dxS4u68NctTLrspEzneZ",
"scope": "*"
}
CURL
curl --location --request POST 'https://api.smartlivraison.com/oauth/token' \
--header 'Content-Type: application/json' \
--data-raw '{
"grant_type":"client_credentials",
"client_id":"3",
"client_secret":"yMfQdO3eSVCWO8QREQUF8dxS4u68NctTLrspEzne",
"scope": "*"
}'
Java - OkHttp
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"grant_type\":\"client_credentials\",\n\t\"client_id\":\"3\",\n\t\"client_secret\":\"yMfQdO3eSVCWO8QREQUF8dxS4u68NctTLrspEzneZ\",\n\t\"scope\": \"*\"\n}");
Request request = new Request.Builder()
.url("https://api.smartlivraison.com/oauth/token")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
PHP - cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.smartlivraison.com/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{\n\t\"grant_type\":\"client_credentials\",\n\t\"client_id\":\"3\",\n\t\"client_secret\":\"yMfQdO3eSVCWO8QREQUF8dxS4u68NctTLrspEzneZ\",\n\t\"scope\": \"*\"\n}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Python - http.client
import http.client
import mimetypes
conn = http.client.HTTPSConnection("api.smartlivraison.com")
payload = "{\n\t\"grant_type\":\"client_credentials\",\n\t\"client_id\":\"3\",\n\t\"client_secret\":\"yMfQdO3eSVCWO8QREQUF8dxS4u68NctTLrspEzneZ\",\n\t\"scope\": \"*\"\n}"
headers = {
'Content-Type': 'application/json'
}
conn.request("POST", "/oauth/token", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))