Access Token - ID Mobile API
Verwenden Sie diesen Endpunkt, um ein IDMobile-Zugriffstoken zu generieren. Das Token ist erforderlich, um alle anderen IDMobile-Scope-Endpunkte aufzurufen.
Verwandte ID Mobile-Dokumentation:
access_token
Anfrage
GET und POST werden beide unterstützt.
{SERVER_ADDRESS} und {LICENCE_CODE} werden von DQE bei der Kontoerstellung bereitgestellt. Wenden Sie sich an Ihren DQE-Kundenbetreuer, um diese Zugangsdaten zu erhalten.
GEThttps://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={LICENCE_CODE}
Codebeispiele
Ein IDMobile-Zugriffstoken anfordern
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/
Fügen Sie die folgenden Parameter im Anfragetext mit Content-Type: application/x-www-form-urlencoded hinzu.
Codebeispiele
Ein IDMobile-Zugriffstoken anfordern
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))
}
Parameter
| Parameter | Beschreibung | Pflicht/Opt |
|---|---|---|
| SERVER_ADDRESS | Adresse des DQE-Servers, der die Daten verarbeitet. | Erforderlich |
| licence | Ihnen zugewiesene Nummer als Lizenzcode. | Erforderlich |
| client_secret | Vom Kunden bereitgestellte Passphrase. | Erforderlich |
| grant_type | Statischer Wert. Muss client_idmobile sein.
Fester Wert: client_idmobile
|
Erforderlich |
Antwort
Die API gibt ein JSON-Objekt mit den folgenden Schlüsseln zurück.
| Schlüssel | Beschreibung | Typ |
|---|---|---|
| access_token | Temporäres Token zum Aufrufen der IDMobile-Dienste. | String |
| token_type |
Bearer: der autorisierte Token-Typ. |
String |
| expires_in | Gültigkeitsdauer des Tokens, in Sekunden. | String |
| refresh_token | Token zur Verlängerung Ihrer Sitzung. | String |
Antwortbeispiel
Beispiel einer Token-Antwort
{
"access_token": "TK948869a6f873adb622enhoaGeVY2iRaptqlmpplGeWZA",
"token_type": "Bearer",
"expires_in": "300",
"refresh_token": "*TK9bdd05f8e9d3c905834bdeqaUlGFll2iRaplll29mZmtkZQ"
}
Fehler
| Fehlertyp | Beispielanfrage | Antwort |
|---|---|---|
Parameter licence fehlt |
https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile |
400 Invalid Request |
Parameter licence ist leer |
https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence= |
400 Invalid Request |
Ungültiger Wert für licence
|
https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={INCORRECT_LICENCE_CODE} |
400 Invalid Client |
Parameter client_secret fehlt oder ist leer |
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 |
Parameter grant_type fehlt oder ist ungültig |
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 |
| Tippfehler im Parameternamen | https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_scret={CLIENT_SECRET}&grant_type=client_idmobile&licence={LICENCE_CODE} |
500 Internal Server Error |
API testen
Klicken Sie auf die Schaltfläche unten, um diesen Endpunkt live in Ihrem Browser zu testen.