Token de acceso - API ID Mobile
Utiliza este endpoint para generar un token de acceso de IDMobile. Este token es necesario para llamar a los demás endpoints de scope de IDMobile.
Documentación de ID Mobile relacionada:
access_token
Solicitud
Se admiten tanto GET como POST.
{SERVER_ADDRESS} y {LICENCE_CODE} son proporcionados por DQE al crear la cuenta. Contacta con tu gestor de cuenta DQE para obtener estas credenciales.
GEThttps://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={LICENCE_CODE}
Ejemplos de código
Solicitar un token de acceso de 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/
Añade los siguientes parámetros en el cuerpo de la solicitud usando Content-Type: application/x-www-form-urlencoded.
Ejemplos de código
Solicitar un token de acceso de 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))
}
Parámetros
| Parámetro | Descripción | Obl / Opc |
|---|---|---|
| SERVER_ADDRESS | Dirección del servidor DQE que procesará los datos. | Obligatorio |
| licence | Número asignado como tu código de licencia. | Obligatorio |
| client_secret | Frase de contraseña proporcionada por el cliente. | Obligatorio |
| grant_type | Valor estático. Debe ser client_idmobile.
Valor fijo: client_idmobile
|
Obligatorio |
Respuesta
La API devuelve un objeto JSON con las siguientes claves.
| Clave | Descripción | Tipo |
|---|---|---|
| access_token | Token temporal utilizado para llamar a los servicios de IDMobile. | String |
| token_type |
Bearer: el tipo de token autorizado. |
String |
| expires_in | Período de validez del token, en segundos. | String |
| refresh_token | Token utilizado para extender tu sesión. | String |
Ejemplo de respuesta
Ejemplo de respuesta del token
{
"access_token": "TK948869a6f873adb622enhoaGeVY2iRaptqlmpplGeWZA",
"token_type": "Bearer",
"expires_in": "300",
"refresh_token": "*TK9bdd05f8e9d3c905834bdeqaUlGFll2iRaplll29mZmtkZQ"
}
Errores
| Tipo de error | Solicitud de ejemplo | Respuesta |
|---|---|---|
Falta el parámetro licence
|
https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile |
400 Invalid Request |
Parámetro licence vacío |
https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence= |
400 Invalid Request |
Valor de licence incorrecto |
https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_secret={CLIENT_SECRET}&grant_type=client_idmobile&licence={INCORRECT_LICENCE_CODE} |
400 Invalid Client |
Parámetro client_secret ausente o vacío |
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 |
Parámetro grant_type ausente o incorrecto |
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 |
| Error tipográfico en el parámetro | https://{SERVER_ADDRESS}/ACCESS_TOKEN/?client_scret={CLIENT_SECRET}&grant_type=client_idmobile&licence={LICENCE_CODE} |
500 Internal Server Error |
Probar la API
Haz clic en el botón de abajo para probar este endpoint en vivo en tu navegador.