# Authentication

[Web version](https://docs.eis.it/en/api/autenticazione)

Generate an API key from **User profile &gt; API Keys** in the Hive portal. `clientId` and the `clientSecret` necessary to get an access token.

## Get the token

Send `POST /auth/api-key/login` with a body `application/x-www-form-urlencoded`:

| Field | Obligation | Description |
| --- | --- | --- |
| `clientId` | Yes. | Client identifier provided by Hive. |
| `clientSecret` | Yes. | API key associated with the 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"
```

An answer `200` contains the field `access_token`. An invalid credential returns `401`.

## Use the token

Send the token to the header of each subsequent request:

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

According to the Hive contract, the access token is valid for 24 hours and the API key for 10 years.

## Protect Credentials

- preserves API key and tokens in a secret manager;
- do not insert them into the source code or in applications executed in the browser;
- do not register them in logs;
- immediately replace an exposed credential.

See the section [Authorization of reference](/en/api/reference/authorization) for the complete endpoint contract.
