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
https://api.smartlivraison.com
/oauth/token
Get Access Token
HTTP
CURL
Java - OkHttp
PHP - cURL
Python - http.client
1
POST /oauth/token HTTP/1.1
2
Host: api.smartlivraison.com
3
Content-Type: application/json
4
5
{
6
"grant_type":"client_credentials",
7
"client_id":"3",
8
"client_secret":"yMfQdO3eSVCWO8QREQUF8dxS4u68NctTLrspEzneZ",
9
"scope": "*"
10
}
Copied!
1
curl --location --request POST 'https://api.smartlivraison.com/oauth/token' \
2
--header 'Content-Type: application/json' \
3
--data-raw '{
4
"grant_type":"client_credentials",
5
"client_id":"3",
6
"client_secret":"yMfQdO3eSVCWO8QREQUF8dxS4u68NctTLrspEzne",
7
"scope": "*"
8
}'
Copied!
1
OkHttpClient client = new OkHttpClient().newBuilder()
2
.build();
3
MediaType mediaType = MediaType.parse("application/json");
4
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}");
5
Request request = new Request.Builder()
6
.url("https://api.smartlivraison.com/oauth/token")
7
.method("POST", body)
8
.addHeader("Content-Type", "application/json")
9
.build();
10
Response response = client.newCall(request).execute();
Copied!
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => "https://api.smartlivraison.com/oauth/token",
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => "",
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "POST",
14
CURLOPT_POSTFIELDS =>"{\n\t\"grant_type\":\"client_credentials\",\n\t\"client_id\":\"3\",\n\t\"client_secret\":\"yMfQdO3eSVCWO8QREQUF8dxS4u68NctTLrspEzneZ\",\n\t\"scope\": \"*\"\n}",
15
CURLOPT_HTTPHEADER => array(
16
"Content-Type: application/json"
17
),
18
));
19
20
$response = curl_exec($curl);
21
22
curl_close($curl);
23
echo $response;
24
Copied!
1
import http.client
2
import mimetypes
3
conn = http.client.HTTPSConnection("api.smartlivraison.com")
4
payload = "{\n\t\"grant_type\":\"client_credentials\",\n\t\"client_id\":\"3\",\n\t\"client_secret\":\"yMfQdO3eSVCWO8QREQUF8dxS4u68NctTLrspEzneZ\",\n\t\"scope\": \"*\"\n}"
5
headers = {
6
'Content-Type': 'application/json'
7
}
8
conn.request("POST", "/oauth/token", payload, headers)
9
res = conn.getresponse()
10
data = res.read()
11
print(data.decode("utf-8"))
Copied!
Last modified 1yr ago
Copy link