Authenticate a user and receive a JWT token
cURL
curl --request POST \ --url https://api.example.com/api/auth/login
{ "success": true, "message": "<string>", "data": { "token": "<string>", "user": { "name": "<string>", "email": "<string>", "role_id": 123 } } }
last_session
Show data properties
Show user properties
curl -X POST https://api.maqagr.com/api/auth/login \ -H "Content-Type: application/json" \ -d '{ "email": "[email protected]", "password": "MiPassword123!" }'
const response = await fetch('https://api.maqagr.com/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: '[email protected]', password: 'MiPassword123!' }) }); const data = await response.json(); const token = data.data.token; // Use token in subsequent requests const protectedResponse = await fetch('https://api.maqagr.com/api/auth/profile', { headers: { 'Authorization': `Bearer ${token}` } });
import requests response = requests.post( 'https://api.maqagr.com/api/auth/login', json={ 'email': '[email protected]', 'password': 'MiPassword123!' } ) data = response.json() token = data['data']['token'] # Use token in subsequent requests protected_response = requests.get( 'https://api.maqagr.com/api/auth/profile', headers={'Authorization': f'Bearer {token}'} )
{ "success": true, "message": "Inicio de sesión exitoso", "data": { "token": "eyJhbGciOiJIUzI1NiIs...", "user": { "name": "Juan Pérez", "email": "[email protected]", "role_id": 2 } } }
{ "success": false, "message": "Email y contraseña son requeridos" }
{ "success": false, "message": "Credenciales inválidas" }
{ "success": false, "message": "Usuario inactivo o suspendido" }
{ "success": false, "message": "Demasiados intentos de inicio de sesión. Por favor, intente de nuevo en 15 minutos." }
{ "success": false, "message": "Error interno del servidor" }