Authentification OAuth2

Support DQE
Support DQE
  • Mise à jour
Jeton d'accès - API OAuth2

Utilisez OAuth2 pour générer un token Bearer temporaire avant d'appeler les API DQE. Le flux utilise votre code de licence, votre client secret et le scope demandé pour renvoyer un jeton d'accès avec une durée de validité limitée.

access_token

Requête

GET et POST sont toutes deux prises en charge.

{SERVER_ADDRESS} et {LICENCE_CODE} sont fournis par DQE à la création du compte. Contactez votre chargé de compte DQE pour obtenir ces identifiants.
GEThttps://{SERVER_ADDRESS}/oauth/access_token/?client_secret={CLIENT_SECRET}&scope={SCOPE}&client_id={LICENCE_CODE}

Exemples de code

Demander un token pour le scope API DQE Adresse

curl "https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client_address&client_id={LICENCE_CODE}"
fetch("https://{SERVER_ADDRESS}/oauth/access_token/?" + new URLSearchParams({ client_secret: "abcd", scope: "client_address", client_id: "{LICENCE_CODE}" })) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.get( "https://{SERVER_ADDRESS}/oauth/access_token/", params={ "client_secret": "abcd", "scope": "client_address", "client_id": "{LICENCE_CODE}", }, ) print(response.json())
<?php $params = http_build_query([ 'client_secret' => 'abcd', 'scope' => 'client_address', 'client_id' => '{LICENCE_CODE}', ]); $ch = curl_init("https://{SERVER_ADDRESS}/oauth/access_token/?{$params}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true);
const axios = require('axios'); axios.get('https://{SERVER_ADDRESS}/oauth/access_token/', { params: { client_secret: 'abcd', scope: 'client_address', client_id: '{LICENCE_CODE}' } }) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String url = "https://{SERVER_ADDRESS}/oauth/access_token/" + "?client_secret=abcd&scope=client_address&client_id={LICENCE_CODE}"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .GET() .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body());
using var client = new HttpClient(); var url = "https://{SERVER_ADDRESS}/oauth/access_token/" + "?client_secret=abcd&scope=client_address&client_id={LICENCE_CODE}"; var response = await client.GetAsync(url); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);
package main import ( "fmt" "io" "net/http" ) func main() { url := "https://{SERVER_ADDRESS}/oauth/access_token/" + "?client_secret=abcd&scope=client_address&client_id={LICENCE_CODE}" resp, err := http.Get(url) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }
POSThttps://{SERVER_ADDRESS}/oauth/access_token/

Envoyez tous les paramètres dans le corps de la requête au format Content-Type: application/x-www-form-urlencoded. L'adresse du serveur reste dans l'URL.

Exemples de code

Demander un token pour le scope API DQE Adresse

curl -X POST "https://{SERVER_ADDRESS}/oauth/access_token/" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "client_id={LICENCE_CODE}" \ -d "client_secret=abcd" \ -d "scope=client_address"
fetch("https://{SERVER_ADDRESS}/oauth/access_token/", { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ client_id: "{LICENCE_CODE}", client_secret: "abcd", scope: "client_address" }) }) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.post( "https://{SERVER_ADDRESS}/oauth/access_token/", data={ "client_id": "{LICENCE_CODE}", "client_secret": "abcd", "scope": "client_address", }, ) print(response.json())
<?php $ch = curl_init("https://{SERVER_ADDRESS}/oauth/access_token/"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'client_id' => '{LICENCE_CODE}', 'client_secret' => 'abcd', 'scope' => 'client_address', ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true);
const axios = require('axios'); const qs = require('querystring'); axios.post('https://{SERVER_ADDRESS}/oauth/access_token/', qs.stringify({ client_id: '{LICENCE_CODE}', client_secret: 'abcd', scope: 'client_address' })) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String form = "client_id={LICENCE_CODE}&client_secret=abcd&scope=client_address"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://{SERVER_ADDRESS}/oauth/access_token/")) .header("Content-Type", "application/x-www-form-urlencoded") .POST(HttpRequest.BodyPublishers.ofString(form)) .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body());
using var client = new HttpClient(); var form = new Dictionary<string, string> { ["client_id"] = "{LICENCE_CODE}", ["client_secret"] = "abcd", ["scope"] = "client_address" }; var response = await client.PostAsync( "https://{SERVER_ADDRESS}/oauth/access_token/", new FormUrlEncodedContent(form)); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);
package main import ( "fmt" "io" "net/http" "net/url" ) func main() { form := url.Values{} form.Set("client_id", "{LICENCE_CODE}") form.Set("client_secret", "abcd") form.Set("scope", "client_address") resp, err := http.PostForm("https://{SERVER_ADDRESS}/oauth/access_token/", form) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }

Paramètres

Paramètre Description Obl / Fac
client_id Numéro qui vous a été attribué comme code de licence. Obligatoire
client_secret Phrase secrète fournie par DQE Software. Obligatoire
scope

Définit le scope d'autorisation demandé. Les valeurs disponibles sont :

  • client_address — API DQE Adresse
  • client_phone — API DQE Téléphone
  • client_email — API DQE Email
  • client_idcheck — API DQE ID Check
  • client_general — plusieurs API DQE
  • client_b2b — API DQE B2B
  • client_civility — API DQE Nom
Obligatoire

Réponse

Si l'authentification réussit, l'API renvoie un dictionnaire JSON contenant les clés suivantes :

Clé Description Type
access_token Token temporaire utilisé pour appeler le service. String
token_type Bearer — type de token autorisé. String
expires_in Durée de validité du token, en secondes. String
refresh_token Token utilisé pour prolonger votre session. String

Exemple de réponse

Exemple de réponse avec token
{ "access_token": "TK948869a6f873adb622enhoaGeVY2iRaptqlmpplGeWZA", "token_type": "Bearer", "expires_in": "300", "refresh_token": "*TK9bdd05f8e9d3c905834bdeqaUlGFll2iRaplll29mZmtkZQ" }

Erreurs

Type d'erreur Exemple de requête Réponse
Paramètre client_id manquant https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client_address 400 Invalid Request
Paramètre client_id vide https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client_address&client_id= 400 Invalid Request
client_id incorrect (expiré, hors scope, ou inexistant) https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client_address&client_id={INCORRECT_LICENCE_CODE} 400 Invalid Client
client_id n'autorise pas le scope demandé https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client_address&client_id={LICENCE_CODE_NOT_AUTHORIZED} 400 Unauthorized Client
Valeur de paramètre scope inconnue https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client&client_id={LICENCE_CODE} 400 Unsupported Grant Type
Paramètre client_secret manquant ou vide https://{SERVER_ADDRESS}/oauth/access_token/?scope=client_address&client_id={LICENCE_CODE}
https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=&scope=client_address&client_id={LICENCE_CODE}
400 Invalid Request
Paramètre scope manquant ou vide https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&client_id={LICENCE_CODE}
https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=&client_id={LICENCE_CODE}
400 Invalid Request
Faute de frappe dans un paramètre https://{SERVER_ADDRESS}/oauth/access_token/?client_scret=abcd&scope=client_address&client_id={LICENCE_CODE} 500 Internal Server Error

Tester l'API

Cliquez sur le bouton ci-dessous pour tester cet endpoint en direct dans votre navigateur.

Ouvrir la console
Rafraîchissement du jeton - API OAuth2

Utilisez cet endpoint pour obtenir un nouveau token d'accès sans répéter le flow d'authentification complet. Passez les access_token et refresh_token reçus précédemment — aucun code de licence ni client secret n'est requis.

refresh_token

Requête

GET et POST sont toutes deux prises en charge.

Aucun code de licence ni client secret nécessaire ici. Le rafraîchissement fait tourner les deux tokens : la réponse renvoie un tout nouveau access_token ET un tout nouveau refresh_token — l'ancienne paire cesse de fonctionner immédiatement, pensez donc à stocker les nouvelles valeurs.
GEThttps://{SERVER_ADDRESS}/oauth/access_token/?scope=refresh_token&access_token={ACCESS_TOKEN}&refresh_token={REFRESH_TOKEN}

Exemples de code

Rafraîchir un token précédemment émis

curl "https://{SERVER_ADDRESS}/oauth/access_token/?scope=refresh_token&access_token={ACCESS_TOKEN}&refresh_token={REFRESH_TOKEN}"
fetch("https://{SERVER_ADDRESS}/oauth/access_token/?" + new URLSearchParams({ scope: "refresh_token", access_token: "{ACCESS_TOKEN}", refresh_token: "{REFRESH_TOKEN}" })) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.get( "https://{SERVER_ADDRESS}/oauth/access_token/", params={ "scope": "refresh_token", "access_token": "{ACCESS_TOKEN}", "refresh_token": "{REFRESH_TOKEN}", }, ) print(response.json())
<?php $params = http_build_query([ 'scope' => 'refresh_token', 'access_token' => '{ACCESS_TOKEN}', 'refresh_token' => '{REFRESH_TOKEN}', ]); $ch = curl_init("https://{SERVER_ADDRESS}/oauth/access_token/?{$params}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true);
const axios = require('axios'); axios.get('https://{SERVER_ADDRESS}/oauth/access_token/', { params: { scope: 'refresh_token', access_token: '{ACCESS_TOKEN}', refresh_token: '{REFRESH_TOKEN}' } }) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String url = "https://{SERVER_ADDRESS}/oauth/access_token/" + "?scope=refresh_token&access_token={ACCESS_TOKEN}&refresh_token={REFRESH_TOKEN}"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .GET() .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body());
using var client = new HttpClient(); var url = "https://{SERVER_ADDRESS}/oauth/access_token/" + "?scope=refresh_token&access_token={ACCESS_TOKEN}&refresh_token={REFRESH_TOKEN}"; var response = await client.GetAsync(url); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);
package main import ( "fmt" "io" "net/http" ) func main() { url := "https://{SERVER_ADDRESS}/oauth/access_token/" + "?scope=refresh_token&access_token={ACCESS_TOKEN}&refresh_token={REFRESH_TOKEN}" resp, err := http.Get(url) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }
POSThttps://{SERVER_ADDRESS}/oauth/access_token/

Envoyez tous les paramètres dans le corps de la requête au format Content-Type: application/x-www-form-urlencoded. L'adresse du serveur reste dans l'URL.

Exemples de code

Rafraîchir un token précédemment émis

curl -X POST "https://{SERVER_ADDRESS}/oauth/access_token/" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "scope=refresh_token" \ -d "access_token={ACCESS_TOKEN}" \ -d "refresh_token={REFRESH_TOKEN}"
fetch("https://{SERVER_ADDRESS}/oauth/access_token/", { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ scope: "refresh_token", access_token: "{ACCESS_TOKEN}", refresh_token: "{REFRESH_TOKEN}" }) }) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.post( "https://{SERVER_ADDRESS}/oauth/access_token/", data={ "scope": "refresh_token", "access_token": "{ACCESS_TOKEN}", "refresh_token": "{REFRESH_TOKEN}", }, ) print(response.json())
<?php $ch = curl_init("https://{SERVER_ADDRESS}/oauth/access_token/"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'scope' => 'refresh_token', 'access_token' => '{ACCESS_TOKEN}', 'refresh_token' => '{REFRESH_TOKEN}', ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true);
const axios = require('axios'); const qs = require('querystring'); axios.post('https://{SERVER_ADDRESS}/oauth/access_token/', qs.stringify({ scope: 'refresh_token', access_token: '{ACCESS_TOKEN}', refresh_token: '{REFRESH_TOKEN}' })) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String form = "scope=refresh_token&access_token={ACCESS_TOKEN}&refresh_token={REFRESH_TOKEN}"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://{SERVER_ADDRESS}/oauth/access_token/")) .header("Content-Type", "application/x-www-form-urlencoded") .POST(HttpRequest.BodyPublishers.ofString(form)) .build(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body());
using var client = new HttpClient(); var form = new Dictionary<string, string> { ["scope"] = "refresh_token", ["access_token"] = "{ACCESS_TOKEN}", ["refresh_token"] = "{REFRESH_TOKEN}" }; var response = await client.PostAsync( "https://{SERVER_ADDRESS}/oauth/access_token/", new FormUrlEncodedContent(form)); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);
package main import ( "fmt" "io" "net/http" "net/url" ) func main() { form := url.Values{} form.Set("scope", "refresh_token") form.Set("access_token", "{ACCESS_TOKEN}") form.Set("refresh_token", "{REFRESH_TOKEN}") resp, err := http.PostForm("https://{SERVER_ADDRESS}/oauth/access_token/", form) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) }

Paramètres

Paramètre Description Obl / Fac
scope Doit être la valeur littérale refresh_token.
Valeur fixe : refresh_token
Obligatoire
access_token Le token d'accès précédemment renvoyé par l'endpoint Access Token. Obligatoire
refresh_token Le token de rafraîchissement précédemment renvoyé par l'endpoint Access Token. Obligatoire

Réponse

Si le rafraîchissement réussit, l'API renvoie la même structure JSON que l'endpoint Access Token — avec une toute nouvelle paire de tokens.

Clé Description Type
access_token Nouveau token temporaire utilisé pour appeler le service. String
token_type Bearer — type de token autorisé. String
expires_in Durée de validité du token, en secondes. String
refresh_token Nouveau token de rafraîchissement — utilisez celui-ci pour le prochain rafraîchissement, l'ancien n'est plus valide. String

Exemple de réponse

Exemple de réponse après rafraîchissement
{ "access_token": "TK948869a6f873adb622enhoaGeVY2iRaptqlmpplGeWZA", "token_type": "Bearer", "expires_in": "300", "refresh_token": "*TK9bdd05f8e9d3c905834bdeqaUlGFll2iRaplll29mZmtkZQ" }

Erreurs

Type d'erreur Exemple de requête Réponse
Paramètre scope, access_token ou refresh_token manquant, vide ou invalide https://{SERVER_ADDRESS}/oauth/access_token/?scope=refresh_token&access_token=&refresh_token={REFRESH_TOKEN} 400 Invalid Request
access_token ou refresh_token expiré ou plus valide https://{SERVER_ADDRESS}/oauth/access_token/?scope=refresh_token&access_token={EXPIRED_TOKEN}&refresh_token={REFRESH_TOKEN} 401 Unauthorized
Faute de frappe dans un paramètre ou problème serveur inattendu https://{SERVER_ADDRESS}/oauth/access_token/?scpoe=refresh_token&access_token={ACCESS_TOKEN}&refresh_token={REFRESH_TOKEN} 500 Internal Server Error

Tester l'API

Cliquez sur le bouton ci-dessous pour tester cet endpoint en direct dans votre navigateur.

Ouvrir la console

Voir aussi

Associé à

Cet article vous a-t-il été utile ?

Utilisateurs qui ont trouvé cela utile : 0 sur 0