> ## Documentation Index
> Fetch the complete documentation index at: https://bkey.id/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Client Credentials

> Authenticate your agent or server using client credentials.

# Client Credentials

The simplest way to authenticate — exchange a `client_id` and `client_secret` for an access token.

## When to Use

* Server-to-server communication
* AI agent authentication
* Background services

## Flow

```http theme={null}
POST /oauth/token
Content-Type: application/json

{
  "grant_type": "client_credentials",
  "client_id": "your-client-id",
  "client_secret": "your-client-secret"
}
```

**Response:**

```json theme={null}
{
  "access_token": "eyJ...",
  "token_type": "Bearer",
  "expires_in": 3600
}
```

## SDK Usage

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { BKeyClient } from '@bkey/sdk';

  const bkey = new BKeyClient({
    clientId: process.env.BKEY_CLIENT_ID!,
    clientSecret: process.env.BKEY_CLIENT_SECRET!,
  });

  // Token is automatically obtained and refreshed
  ```

  ```python Python theme={null}
  from bkey import BKeyClient

  client = BKeyClient(
      client_id="your-client-id",
      client_secret="your-client-secret",
  )

  # Token is automatically obtained and refreshed
  ```
</CodeGroup>
