ID Mobile — Générer un token d'accès

Support DQE
Support DQE
  • Mise à jour
Access Token - API ID Mobile

Utilisez cet endpoint pour générer un jeton d'accès IDMobile. Ce jeton est nécessaire pour appeler tous les autres endpoints de scope IDMobile.

Documentation ID Mobile associé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}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={LICENCE_CODE}

Exemples de code

Demander un jeton d'accès IDMobile

curl "https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={LICENCE_CODE}"
fetch("https://{SERVER_ADDRESS}/ACCESS_TOKEN/?" + new URLSearchParams({ client_secret: "{CLIENT_SECRET}", grant_type: "client_idmobile", licence: "{LICENCE_CODE}" })) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.get( "https://{SERVER_ADDRESS}/ACCESS_TOKEN/", params={ "client_secret": "{CLIENT_SECRET}", "grant_type": "client_idmobile", "licence": "{LICENCE_CODE}", }, ) print(response.json())
<?php $params = http_build_query([ 'client_secret' => '{CLIENT_SECRET}', 'grant_type' => 'client_idmobile', 'licence' => '{LICENCE_CODE}', ]); $ch = curl_init("https://{SERVER_ADDRESS}/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}/ACCESS_TOKEN/', { params: { client_secret: '{CLIENT_SECRET}', grant_type: 'client_idmobile', licence: '{LICENCE_CODE}' } }) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String url = "https://{SERVER_ADDRESS}/ACCESS_TOKEN/" + "?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={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}/ACCESS_TOKEN/" + "?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={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}/ACCESS_TOKEN/" + "?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={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}/ACCESS_TOKEN/

Ajoutez les paramètres suivants dans le corps de la requête au format Content-Type: application/x-www-form-urlencoded.

Exemples de code

Demander un jeton d'accès IDMobile

curl -X POST "https://{SERVER_ADDRESS}/ACCESS_TOKEN/" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "licence={LICENCE_CODE}" \ -d "client_secret={CLIENT_SECRET}" \ -d "grant_type=client_idmobile"
fetch("https://{SERVER_ADDRESS}/ACCESS_TOKEN/", { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams({ licence: "{LICENCE_CODE}", client_secret: "{CLIENT_SECRET}", grant_type: "client_idmobile" }) }) .then(r => r.json()) .then(data => console.log(data));
import requests response = requests.post( "https://{SERVER_ADDRESS}/ACCESS_TOKEN/", data={ "licence": "{LICENCE_CODE}", "client_secret": "{CLIENT_SECRET}", "grant_type": "client_idmobile", }, ) print(response.json())
<?php $ch = curl_init("https://{SERVER_ADDRESS}/ACCESS_TOKEN/"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ 'licence' => '{LICENCE_CODE}', 'client_secret' => '{CLIENT_SECRET}', 'grant_type' => 'client_idmobile', ])); 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}/ACCESS_TOKEN/', qs.stringify({ licence: '{LICENCE_CODE}', client_secret: '{CLIENT_SECRET}', grant_type: 'client_idmobile' })) .then(response => console.log(response.data));
HttpClient client = HttpClient.newHttpClient(); String form = "licence={LICENCE_CODE}&client_secret={CLIENT_SECRET}&grant_type=client_idmobile"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://{SERVER_ADDRESS}/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> { ["licence"] = "{LICENCE_CODE}", ["client_secret"] = "{CLIENT_SECRET}", ["grant_type"] = "client_idmobile" }; var response = await client.PostAsync( "https://{SERVER_ADDRESS}/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("licence", "{LICENCE_CODE}") form.Set("client_secret", "{CLIENT_SECRET}") form.Set("grant_type", "client_idmobile") resp, err := http.PostForm("https://{SERVER_ADDRESS}/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 / Opt
SERVER_ADDRESS Adresse du serveur DQE qui traitera les données. Obligatoire
licence Numéro attribué en tant que code de licence. Obligatoire
client_secret Phrase secrète fournie par le client. Obligatoire
grant_type Valeur statique. Doit être client_idmobile.
Valeur fixe : client_idmobile
Obligatoire

Réponse

L'API renvoie un objet JSON contenant les clés suivantes.

Clé Description Type
access_token Jeton temporaire utilisé pour appeler les services IDMobile. String
token_type Bearer : le type de jeton autorisé. String
expires_in Durée de validité du jeton, en secondes. String
refresh_token Jeton utilisé pour prolonger votre session. String

Exemple de réponse

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

Erreurs

Type d'erreur Exemple de requête Réponse
Paramètre licence manquant https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile 400 Invalid Request
Paramètre licence vide https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence= 400 Invalid Request
Valeur licence incorrecte https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={INCORRECT_LICENCE_CODE} 400 Invalid Client
Paramètre client_secret manquant ou vide https://{SERVER_ADDRESS}/ACCESS_TOKEN/?grant_type=client_idmobile&licence={LICENCE_CODE}
https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret=&grant_type=client_idmobile&licence={LICENCE_CODE}
400 Invalid Request
Paramètre grant_type manquant ou incorrect https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&licence={LICENCE_CODE}
https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=wrong_value&licence={LICENCE_CODE}
400 Invalid Request
Faute de frappe sur un paramètre https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_scret={CLIENT_SECRET}&grant_type=client_idmobile&licence={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

Voir aussi

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

Utilisateurs qui ont trouvé cela utile : 0 sur 0