Autenticazione
Scambia le tue credenziali con un token bearer e invialo a ogni chiamata.
POST
/api/v1/auth/tokenRiferimento →
Le API usano OAuth 2.0 con il flusso client credentials. VolantinoPiù ti dà un client ID e un client secret: li scambi con un token bearer a breve scadenza, e invii quel token a ogni chiamata.
Ottieni un token
POST /api/v1/auth/token accetta un corpo JSON o form-encoded con client_id e client_secret.
curl -X POST "$VPIU_API/api/v1/auth/token" \
-H "Content-Type: application/json" \
-d '{
"client_id": "'"$VPIU_CLIENT_ID"'",
"client_secret": "'"$VPIU_CLIENT_SECRET"'"
}'| Campo | Tipo | Descrizione |
|---|---|---|
access_token | string | Il token bearer, un JWT. |
token_type | string | Sempre Bearer. |
expires_in | integer | Secondi alla scadenza del token. |
{ "access_token": "eyJ...", "token_type": "Bearer", "expires_in": 43199 }La risposta non viene mai messa in cache (Cache-Control: no-store). Tieni il token in memoria, non nei log.
Usa il token
Authorization: Bearer <access_token>- Riusa il token finché non scade.
- Se una chiamata risponde
401, il token manca, è scaduto o non è valido: chiedine uno nuovo e riprova la chiamata una volta. - Un
403non è un problema di token: il token è valido ma non può leggere quel tenant. Vedi Tenant.
Errori
| HTTP | message | Cosa fare |
|---|---|---|
| 400 | Una voce per ogni campo non valido, es. client_id should not be empty | Invia entrambi i campi, al massimo 512 caratteri ciascuno. |
| 401 | invalid client credentials | Controlla client ID e secret. |
| 502 | identity provider unavailable | Riprova dopo qualche secondo. |
| 502 | machine user is not configured for JWT access tokens | Il tuo client è configurato male da parte nostra: contatta VolantinoPiù. |
Se un secret finisce nelle mani sbagliate, chiedi a VolantinoPiù di sostituirlo.