> ## 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.

# Autenticazione

Per l'autenticazione dell'API utilizziamo OAuth 2.0. Scopri come generare e usare i token di accesso in modo sicuro seguendo le nostre best practice.

Assicurati di includere in ogni richiesta che invii l'intestazione `Authorization` con lo schema `Bearer` e il tuo token di accesso.

## Generare un token di accesso

Prima di effettuare richieste API, devi ottenere un token di accesso inviando una richiesta all'endpoint [Generare un token di accesso](https://docs.localpayment.com/it/reference/get-token.md).

### Esempio di richiesta

```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>"
}
'
```

### Esempio di risposta

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

***

## Usare il token di accesso

Una volta ricevuto il token `access`, includilo nell'intestazione `Authorization` come token Bearer in tutte le richieste API successive.

### Esempio di richiesta

```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 le informazioni dettagliate sull'[autenticazione](https://docs.localpayment.com/it/reference/authentication-overview.md).

### Best practice per l'uso delle credenziali

Le tue credenziali API sono fondamentali per la tua integrazione con Localpayment. Proteggile seguendo queste best practice:

* Conserva le credenziali in modo sicuro tramite variabili d'ambiente o gestori di segreti: non scriverle mai direttamente nel codice e non includerle mai nei commit del sistema di controllo versione.
* Limita l'accesso ai membri autorizzati del team e revoca qualsiasi credenziale che sospetti sia stata compromessa.
* Usa credenziali separate per l'ambiente sandbox e per l'ambiente di produzione.
* Monitora regolarmente i log dell'API per individuare attività insolite.
* Non esporre mai le credenziali nel codice lato client, nelle app mobili o nei repository pubblici.


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