Authentification avec un token OAuth2

Pour s’authentifier lors de l’utilisation d’un service, il faut insérer le token dans l’en-tête HTTP de votre appel, avec le format suivant : Authorization: Bearer XXXX-XXXX-XXXX-XXXX-XXXX

Exemple d’appel SSO authentifié avec CURL :

curl -H "Authorization: Bearer XXXX-XXXX-XXXX-XXXX-XXXX" "http://api.apidae-tourisme.com/api/v002/sso/utilisateur/profil"

Exemple d’appel API d’écriture authentifié en PHP :

<?php

$token = "XXXX-XXXX-XXXX-XXXX-XXXX";

$formParameters = array();
$formParameters["id"] = 999666;
$formParameters["mode"] = 'MODIFICATION';
$formParameters["fields"] = json_encode(array());

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Bearer ".$token));
curl_setopt($ch, CURLOPT_URL, "http://api.apidae-tourisme.com/api/v002/ecriture/");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
curl_setopt($ch, CURLOPT_POSTFIELDS, $formParameters);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

print_r(curl_exec($ch));

?>