Skip to main content

GET /usuarios/me

Returns the profile information for the currently authenticated user based on the JWT token.

Authentication

Required: Bearer token (JWT) in the Authorization header
This endpoint requires a valid JWT token. Any authenticated user (visitante, editor, or admin) can access their own profile.

Request

No request body or parameters required. The user is identified from the JWT token.
cURL
curl -X GET "http://localhost:8000/usuarios/me" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Python
import requests

url = "http://localhost:8000/usuarios/me"
headers = {
    "Authorization": "Bearer YOUR_JWT_TOKEN"
}

response = requests.get(url, headers=headers)
print(response.json())
JavaScript
const response = await fetch('http://localhost:8000/usuarios/me', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_JWT_TOKEN'
  }
});

const user = await response.json();
console.log(user);

Response

id
string
User’s unique identifier (MongoDB ObjectId)
nombre
string
User’s full name
email
string
User’s email address
rol
string
User’s role: visitante, editor, or admin

Example Response

{
  "id": "507f1f77bcf86cd799439011",
  "nombre": "Juan Pérez",
  "email": "[email protected]",
  "rol": "visitante"
}

Error Responses

Status CodeDescription
401Unauthorized - Invalid or missing JWT token
403Forbidden - Token expired or malformed

Use Cases

  • Display user profile information in the frontend
  • Verify the current user’s role before showing role-specific UI
  • Fetch user details after login
  • Check authentication status

Implementation Reference

This endpoint is implemented in src/infrastructure/api/routers/usuario_router.py:24-32:
@router.get("/me")
def get_me(token_data = Depends(get_current_user)):
    """Devuelve los datos del usuario autenticado."""
    return {
        "id": token_data.id,
        "nombre": token_data.nombre,
        "email": token_data.email,
        "rol": token_data.rol
    }
The get_current_user dependency (from jwt_utils.py) decodes the JWT token and returns the user data.

Build docs developers (and LLMs) love