Passo 3: ottenere un token OAuth2

Ottenere un token OAuth2 dall'Identity Server eConnect (Client Credentials), usarlo come Bearer token e rinnovarlo.

Ogni chiamata PSB richiede un Bearer token dall'Identity Server. I token sono validi 3600 secondi di default.

Client Credentials (consigliato)
POST /connect/token HTTP/1.1
Host: accp-identity.econnect.eu
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id=your-client-id
&client_secret=your-client-secret
&scope=ap
curl
curl -s -X POST https://accp-identity.econnect.eu/connect/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=your-client-id" \
  -d "client_secret=your-client-secret" \
  -d "scope=ap"
Risposta di successo
{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expires_in": 3600,
  "token_type": "Bearer",
  "scope": "ap"
}
Usare il token
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

Invia questa header con ogni richiesta a accp-psb.econnect.eu. Non valido o scaduto → 401 Unauthorized.

Rinnovo

Non c'è un flusso refresh-token separato per Client Credentials: richiedi di nuovo un token (ad esempio dopo ~3500 s) così le chiamate non falliscono a metà batch.

Altro flusso

I diritti passano da un account utente del cliente finale? Usa Resource Owner Password Credentials, spiegato per intero in Autenticazione.

Passo successivo

Prima chiamata API (GET /me)