application/x-www-form-urlencoded
le CLIENT_ID de votre compte développeur
le CLIENT_SECRET de votre compte développeur
Un exemple d'implémentation dans différents langages est disponible ci-dessous:
cURL :
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=CLIENT_ID" \
-d "client_secret=CLIENT_SECRET" \
"https://accountsandbox.hubintent.com/oauth/token"
PHP :
curl_setopt_array($curl, array(
CURLOPT_URL => "https://accountsandbox.hubintent.com/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
$response = curl_exec($curl);
$err = curl_error($curl);
echo "cURL Error #:" . $err;
NodeJS :
var qs = require("querystring");
var http = require("https");
"hostname": "accountsandbox.hubintent.com",
"content-type": "application/x-www-form-urlencoded",
"cache-control": "no-cache"
var req = http.request(options, function (res) {
res.on("data", function (chunk) {
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
req.write(qs.stringify({ grant_type: 'client_credentials',
client_secret: 'CLIENT_SECRET' }));
Python :
conn = http.client.HTTPSConnection("accountsandbox.hubintent.com")
payload = "grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET"
'content-type': "application/x-www-form-urlencoded",
'cache-control': "no-cache"
conn.request("POST", "/oauth/token", payload, headers)
print(data.decode("utf-8"))
Java :
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET");
Request request = new Request.Builder()
.url("https://accountsandbox.hubintent.com/oauth/token")
.addHeader("content-type", "application/x-www-form-urlencoded")
.addHeader("cache-control", "no-cache")
Response response = client.newCall(request).execute();
RestSharpe :
var client = new RestClient("https://accountsandbox.hubintent.com/oauth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
En réponse, vous recevrez un access_token :
JSON :
"access_token":"bc378d50dca644816b777afd26d21e7260bb8296",
Cet access_token devra être utilisé pour chaque requête vers l'API intent, sous forme de header :
Authorization : Bearer access_token