Token de acceso - API OAuth2
Utilice OAuth2 para generar un token Bearer temporal antes de llamar a las API de DQE. El flujo utiliza su código de licencia, su client secret y el scope solicitado para devolver un token de acceso con un período de validez limitado.
⬇ Descargar spec OpenAPI 3.2.1 (JSON)
access_token
Solicitud
Se admiten tanto GET como POST.
{SERVER_ADDRESS} y {LICENCE_CODE} son proporcionados por DQE al crear su cuenta. Póngase en contacto con su gestor de cuenta de DQE para obtener estas credenciales.
GET
POST
GET https://{SERVER_ADDRESS}/oauth/access_token/?client_secret ={CLIENT_SECRET}&scope ={SCOPE}&client_id ={LICENCE_CODE}
Ejemplos de código
Solicitud de token para el scope DQE Address
cURL
JavaScript
Python
PHP
Node.js
Java
C#
Go
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))
}
POST https://{SERVER_ADDRESS}/oauth/access_token/
Envíe todos los parámetros en el cuerpo de la solicitud usando Content-Type: application/x-www-form-urlencoded. La dirección del servidor permanece en la URL.
Ejemplos de código
Solicitud de token para el scope DQE Address
cURL
JavaScript
Python
PHP
Node.js
Java
C#
Go
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))
}
Parámetros
Parámetro
Descripción
Obl / Opc
client_id
Número asignado como su código de licencia.
Obligatorio
client_secret
Frase de contraseña proporcionada por DQE Software.
Obligatorio
scope
Define el ámbito de autorización solicitado. Los valores disponibles incluyen:
client_address — DQE Address APIs
client_phone — DQE Phone APIs
client_email — DQE Email APIs
client_idcheck — DQE ID Check APIs
client_general — múltiples API de DQE
client_b2b — DQE B2B APIs
client_civility — DQE Name APIs
Obligatorio
Respuesta
Si la autenticación se realiza correctamente, la API devuelve un diccionario JSON que contiene las siguientes claves.
Clave
Descripción
Tipo
access_token
Token temporal utilizado para llamar al servicio.
String
token_type
Bearer — tipo de token autorizado.
String
expires_in
Período de validez del token, en segundos.
String
refresh_token
Token utilizado para prolongar su sesión.
String
Ejemplo de respuesta
Ejemplo de respuesta de token
{
"access_token" : "TK948869a6f873adb622enhoaGeVY2iRaptqlmpplGeWZA" ,
"token_type" : "Bearer" ,
"expires_in" : "300" ,
"refresh_token" : "*TK9bdd05f8e9d3c905834bdeqaUlGFll2iRaplll29mZmtkZQ"
}
Errores
Tipo de error
Ejemplo de solicitud
Respuesta
Falta el parámetro client_id
https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client_address
400 Invalid Request
Parámetro client_id vacío
https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client_address&client_id=
400 Invalid Request
client_id incorrecto (caducado, fuera de ámbito o inexistente)
https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client_address&client_id={INCORRECT_LICENCE_CODE}
400 Invalid Client
client_id no autoriza el scope solicitado
https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client_address&client_id={LICENCE_CODE_NOT_AUTHORIZED}
400 Unauthorized Client
Valor del parámetro scope desconocido
https://{SERVER_ADDRESS}/oauth/access_token/?client_secret=abcd&scope=client&client_id={LICENCE_CODE}
400 Unsupported Grant Type
Parámetro client_secret faltante o vacío
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
Parámetro scope faltante o vacío
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
Error tipográfico en un parámetro
https://{SERVER_ADDRESS}/oauth/access_token/?client_scret=abcd&scope=client_address&client_id={LICENCE_CODE}
500 Internal Server Error
Probar la API
Haga clic en el botón de abajo para probar este endpoint en vivo desde su navegador.
Abrir consola
Token de actualización - API OAuth2
Utilice este endpoint para obtener un nuevo token de acceso sin repetir todo el flujo de autenticación. Indique el access_token y el refresh_token que recibió anteriormente — no se necesita código de licencia ni client secret.
⬇ Descargar spec OpenAPI 3.2.1 (JSON)
refresh_token
Solicitud
Se admiten tanto GET como POST.
No se necesita código de licencia ni client secret aquí. Al actualizar se rotan ambos tokens: la respuesta devuelve un nuevo access_token Y un nuevo refresh_token — el par anterior deja de funcionar inmediatamente, así que guarde los nuevos valores.
GET
POST
GET https://{SERVER_ADDRESS}/oauth/access_token/?scope =refresh_token&access_token ={ACCESS_TOKEN}&refresh_token ={REFRESH_TOKEN}
Ejemplos de código
Actualización de un token emitido anteriormente
cURL
JavaScript
Python
PHP
Node.js
Java
C#
Go
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))
}
POST https://{SERVER_ADDRESS}/oauth/access_token/
Envíe todos los parámetros en el cuerpo de la solicitud usando Content-Type: application/x-www-form-urlencoded. La dirección del servidor permanece en la URL.
Ejemplos de código
Actualización de un token emitido anteriormente
cURL
JavaScript
Python
PHP
Node.js
Java
C#
Go
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))
}
Parámetros
Parámetro
Descripción
Obl / Opc
scope
Debe ser el valor literal refresh_token.
Valor fijo: refresh_token
Obligatorio
access_token
El access token devuelto previamente por el endpoint Access Token.
Obligatorio
refresh_token
El refresh token devuelto previamente por el endpoint Access Token.
Obligatorio
Respuesta
Si la actualización se realiza correctamente, la API devuelve la misma estructura JSON que el endpoint Access Token — con un nuevo par de tokens.
Clave
Descripción
Tipo
access_token
Nuevo token temporal utilizado para llamar al servicio.
String
token_type
Bearer — tipo de token autorizado.
String
expires_in
Período de validez del token, en segundos.
String
refresh_token
Nuevo refresh token — utilice este para la próxima actualización, el anterior ya no es válido.
String
Ejemplo de respuesta
Ejemplo de respuesta de token renovado
{
"access_token" : "TK948869a6f873adb622enhoaGeVY2iRaptqlmpplGeWZA" ,
"token_type" : "Bearer" ,
"expires_in" : "300" ,
"refresh_token" : "*TK9bdd05f8e9d3c905834bdeqaUlGFll2iRaplll29mZmtkZQ"
}
Errores
Tipo de error
Ejemplo de solicitud
Respuesta
Parámetro scope, access_token o refresh_token faltante, vacío o inválido
https://{SERVER_ADDRESS}/oauth/access_token/?scope=refresh_token&access_token=&refresh_token={REFRESH_TOKEN}
400 Invalid Request
access_token o refresh_token caducado o ya no válido
https://{SERVER_ADDRESS}/oauth/access_token/?scope=refresh_token&access_token={EXPIRED_TOKEN}&refresh_token={REFRESH_TOKEN}
401 Unauthorized
Error tipográfico en un parámetro o problema inesperado del servidor
https://{SERVER_ADDRESS}/oauth/access_token/?scpoe=refresh_token&access_token={ACCESS_TOKEN}&refresh_token={REFRESH_TOKEN}
500 Internal Server Error
Probar la API
Haga clic en el botón de abajo para probar este endpoint en vivo desde su navegador.
Abrir consola