Acceso y Autenticación
Whitelist de IPs
Antes de poder consumir la API de Allaria, es obligatorio whitelistear la dirección IP desde la cual tu aplicación realizará los requests. Sin esta configuración, la API no responderá a tus requests.
Pasos para agregar tu IP al whitelist
-
Contacta a soporte
- Envía un email a platform@allaria.com.ar
- Proporciona:
- Tu
client_id(o nombre de la aplicación) - La dirección IP pública que necesitas whitelistear
- Tu
-
Confirmación
- El equipo de soporte confirmará cuando tu IP haya sido agregada al whitelist
- Una vez confirmado, podrás comenzar a hacer requests a la API
Si intentas hacer un request desde una IP no whitelisteada, el request expirará por timeout (la API no responderá). Verifica que tu IP está correctamente whitelisteada antes de contactar a soporte.
Autenticación M2M (Machine-to-Machine)
Una vez que tu IP esté whitelisteada, utiliza tu client_id y client_secret para obtener un token de acceso (access_token) que te permitirá realizar llamadas autenticadas a la API.
Request
- cURL
- JavaScript
- Python
- Node.js
curl -X POST https://b2b.allaria.dev/auth/m2m/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=TU_CLIENT_ID&client_secret=TU_CLIENT_SECRET&grant_type=client_credentials"
const response = await fetch('https://b2b.allaria.dev/auth/m2m/token', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
client_id: 'TU_CLIENT_ID',
client_secret: 'TU_CLIENT_SECRET',
grant_type: 'client_credentials'
})
});
const data = await response.json();
console.log(data.access_token);
import requests
response = requests.post(
'https://b2b.allaria.dev/auth/m2m/token',
headers={'Content-Type': 'application/x-www-form-urlencoded'},
data={
'client_id': 'TU_CLIENT_ID',
'client_secret': 'TU_CLIENT_SECRET',
'grant_type': 'client_credentials'
}
)
data = response.json()
access_token = data['access_token']
const axios = require('axios');
const response = await axios.post('https://b2b.allaria.dev/auth/m2m/token',
new URLSearchParams({
client_id: 'TU_CLIENT_ID',
client_secret: 'TU_CLIENT_SECRET',
grant_type: 'client_credentials'
}),
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
);
const accessToken = response.data.access_token;
Parámetros de Request
| Parámetro | Tipo | Requerido | Descripción |
|---|---|---|---|
client_id | string | Sí | Tu identificador de cliente proporcionado por Allaria |
client_secret | string | Sí | Tu secreto de cliente (mantén confidencial) |
grant_type | string | Sí | Debe ser: client_credentials |
Response
Status: 200 OK
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_in": 86400,
"scope": "api"
}
| Campo | Tipo | Descripción |
|---|---|---|
access_token | string | Token para autenticar requests posteriores |
token_type | string | Tipo de token (siempre Bearer) |
expires_in | integer | Tiempo en segundos antes de que el token expire (86400 segundos = 1 día) |
scope | string | Alcances de permisos del token |
Códigos de Error
| Status | Error | Descripción |
|---|---|---|
| 400 | invalid_request | Parámetros faltantes o inválidos |
| 401 | invalid_client | client_id o client_secret inválidos |
| 403 | access_denied | Acceso denegado a la API |
| 500 | server_error | Error interno del servidor |
Ejemplo de respuesta de error:
{
"error": "invalid_client",
"error_description": "Client authentication failed (e.g. unknown client, no client authentication included, or unsupported authentication method)"
}
Usando el Token en Requests
Una vez obtenido el access_token, inclúyelo en el header Authorization de tus requests:
- cURL
- JavaScript
- Python
curl -X GET https://b2b.allaria.dev/v1/accounts \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json"
const accessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
const response = await fetch('https://b2b.allaria.dev/v1/accounts', {
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
});
const data = await response.json();
import requests
access_token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json'
}
response = requests.get('https://b2b.allaria.dev/v1/accounts', headers=headers)
data = response.json()
Nunca expongas tu client_secret en código de cliente. Siempre genera tokens en tu servidor backend y envíalos de forma segura al cliente.