> ## Documentation Index
> Fetch the complete documentation index at: https://docs.localpayment.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Autenticación

Utilizamos OAuth 2.0 para la autenticación de API. Aprende cómo generar y usar tokens de acceso de forma segura siguiendo nuestras mejores prácticas.

Asegúrate de incluir el encabezado `Authorization` con el esquema `Bearer` y tu token de acceso en cada solicitud que envíes.

## Generar un token de acceso

Antes de realizar solicitudes a la API, debes obtener un token de acceso enviando una solicitud al endpoint [Generar un token de acceso](https://docs.localpayment.com/es/reference/get-token.md).

### Ejemplo de solicitud

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request POST \
     --url https://api.stage.localpayment.com/api/token/ \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "username": "user@example.com",
  "password": "<PASSWORD>"
}
'
```

### Ejemplo de respuesta

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "refresh": "eyJ0eXAiOiJKV1QiLCJhbGccM5kYO7o4iOiJIU18jaiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTczNTMxOTkyOSwianRpIjoiZWUxMDE3MTUwY2JhNGM1NTg0MjYyZmRkZTdiOThiNGQiLCJ1c2VyX2lkIjoxMDAwLCJzdXBlcnVzZXIiOnRydWUsImlzX3N0YWZmIjp0cnVlLCJybaCIsImV4cCI62xlcyI6WyJBTEwiXSwiY291bnRyaWVzIjpbIkFMTCJdLCJjb21wYW55IjoiQUxMIiwiY2xpZW50X2NvZGUiOiJBNzaW9uTEwiLCJwZXJtaXcyI6W119.6siymomkQ72yMvHGU9sMCO4h-cxpNgQXor",
  "access": "eyJ0eXAiOiJKV1QiLCJhJIUzI1NiJ9.eyJ0b2tlbl90eXBlIbGciOijoiYWNjZXNzIiwiZXhwIjoxNzM1MjMzODI5LCJqdGkiOiJiMDRmNzQ3YWEjOCIsIn4Mjg0YjM0YmMwN2Y4ZjVkOWM0NWFVzZXJfaWQiOjEwMDAsInN1cGVydXNlciI6dHJ1ZSwiaXNfc3RhZmYiOnRy3VudHJpZXMiOljpbIkFsiQUxMIl0sImNvbXBhbnkiOiJBTEwiLCJjbGllbnRfY29kZSI6IkFMTCIsInBlcm1pc3Npb25zIjpdWUsInJvbGVzIMTCJdLlqEnH7GrECJjbbXX0.sWOLKFxCcXQkUcPvTjYceXBp39hDF3-Snc"
}
```

***

## Utiliza el token de acceso.

Una vez que recibas el token `access`, inclúyelo en el encabezado `Authorization` como token Bearer en todas las solicitudes posteriores a la API.

### Ejemplo de solicitud

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request POST \
     --url https://api.stage.localpayment.com/api/validation/document \
     --header 'Authorization: Bearer <your_access_token>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "country": "ARG",
  "document": {
    "id": "1791234561009",
    "type": "RUC"
  }
}
'
```

Consulta información detallada sobre la [autenticación](https://docs.localpayment.com/es/reference/authentication-overview.md).

### Buenas prácticas para el uso de credenciales

Tus credenciales de API son fundamentales para la integración con Localpayment. Manténlas seguras siguiendo estas buenas prácticas:

* Almacena las credenciales de forma segura utilizando variables de entorno o gestores de secretos; nunca las codifiques directamente en el código ni las incluyas en el control de versiones.
* Limita el acceso a los miembros del equipo autorizados y revoca cualquier credencial que sospeches que está comprometida.
* Utiliza credenciales diferentes para los entornos de pruebas (Sandbox) y de producción.
* Supervisa los registros de la API periódicamente para detectar actividades inusuales.
* Nunca expongas las credenciales en el código del cliente, en aplicaciones móviles o en repositorios públicos.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.