> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.eis.it/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.eis.it/_mcp/server.

# Autenticazione

> Flusso di autenticazione delle API Hive: API key, clientId, clientSecret e access token Bearer.

Genera una API key da **Profilo utente > API Keys** nel portale Hive. Il portale fornisce il `clientId` e il `clientSecret` necessari per ottenere un access token.

## Ottenere il token

Invia `POST /auth/api-key/login` con un body `application/x-www-form-urlencoded`:

| Campo          | Obbligatorio | Descrizione                            |
| -------------- | ------------ | -------------------------------------- |
| `clientId`     | Sì           | Identificativo client fornito da Hive. |
| `clientSecret` | Sì           | API key associata al client.           |

```bash
curl --request POST \
  --url "https://api.eis.it/auth/api-key/login" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode "clientId=$EIS_CLIENT_ID" \
  --data-urlencode "clientSecret=$EIS_CLIENT_SECRET"
```

Una risposta `200` contiene il campo `access_token`. Una credenziale non valida restituisce `401`.

## Usare il token

Invia il token nell'header di ogni richiesta successiva:

```http
Authorization: Bearer <access_token>
```

Secondo il contratto Hive, l'access token è valido per 24 ore e l'API key per 10 anni.

## Proteggere le credenziali

* conserva API key e token in un secret manager;
* non inserirli nel codice sorgente o in applicazioni eseguite nel browser;
* non registrarli nei log;
* sostituisci immediatamente una credenziale esposta.

Consulta la sezione [Authorization della reference](/api/reference/authorization) per il contratto completo dell'endpoint.