---
title: Authentication
description: Every API request needs a JWT bearer token in the Authorization header.
canonical: 'https://lightning.ai/docs/platform/cluster/access/authentication'
---
# Authentication {#authentication}

Every API request needs a JWT bearer token in the `Authorization` header:

```http
Authorization: Bearer <token>
```

Tokens identify both **who** is calling and **which organization** they belong to. All results are automatically scoped to that organization.

## Principals {#principals}

Lightning AI provisions an **Administrator User Principal** and an **Application Principal** for your organization, and delivers both through an encrypted channel. If you have not received yours, contact [support](/docs/platform/cluster/support.md). The Administrator then creates User Principals for the rest of the team in the console (in ORD1 first, with other regions to follow). See [Managing users](/docs/platform/cluster/access/roles-permissions.md#managing-users).

| Principal | Used by | How it authenticates |
|-----------|---------|----------------------|
| **User Principal** | People using the console, and the CLI to get API tokens | Interactive sign-in through the browser |
| **Application Principal** | Services, CI pipelines, automation | A `clientId` and `clientSecret`, which the [Python SDK](/docs/platform/cluster/get-started/python-sdk.md) exchanges for tokens |

Use a User Principal for interactive work and an Application Principal for anything unattended. Don't share User Principal credentials with automation.

## Getting a token with the Lightning Cloud CLI {#getting-a-token-with-the-lightning-cloud-cli}

The CLI signs you in as a User Principal. For automation with an Application Principal, use the [Python SDK](/docs/platform/cluster/get-started/python-sdk.md) instead. It gets and refreshes tokens from the client ID and secret.

[Install the CLI](/docs/platform/cluster/access/cli.md), then sign in. The CLI uses the OAuth 2.0 device authorization flow. It opens a browser to finish the sign-in, then caches and refreshes the token for you.

```bash
harbor auth login                 # sea1 by default
harbor auth login --region iad1   # another region
harbor auth status                # identity, organization, and expiry
harbor auth token                 # prints the raw access token
harbor auth logout
```

Tokens are cached per region under `~/.harbor/` and refreshed automatically before they expire. Each command picks its region separately, and `login` doesn't change the default, so pass the same `--region` to `login` and `token`. Use `harbor auth token` anywhere a token is needed:

```bash
export TOKEN=$(harbor auth token --region sea1)
curl "$API_URL/v1/fleets" -H "Authorization: Bearer $TOKEN"
```

## Token scope {#token-scope}

- **Region**: a token is valid only for the region it was issued for. See [Regions & endpoints](/docs/platform/cluster/get-started/regions.md).
- **Organization**: a token can only see and change its own organization's resources. Requests for another organization's fleet return `404 Not Found`.
- **Expiry**: tokens are short-lived. When a call returns `401 Unauthorized`, get a fresh token. The CLI does this automatically.

## Roles {#roles}

Each person in your organization is either a **User** or an **Administrator**. Users can view and operate fleets. Administrators can also control node power, manage SSH keys, read audit logs, and manage users. A request that your role doesn't allow returns `403 Forbidden`.

See [Roles & permissions](/docs/platform/cluster/access/roles-permissions.md) for the full list.

## Security recommendations {#security-recommendations}

- Store client secrets in a secrets manager, never in source control.
- Never log full tokens. `harbor auth status` shows token metadata without printing the token.
- Treat a downloaded kubeconfig as a credential. See [Managed Kubernetes](/docs/platform/cluster/managed-kubernetes.md).
- Review activity regularly with [audit logs](/docs/platform/cluster/audit-logs.md).

---

**Navigation**

- Parent: [Access & identity](/docs/platform/cluster/access.md)
