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

# Get OAuth2 Access Token

> Returns the current access token for an OAuth2 secret, refreshing it automatically if expired

## Get OAuth2 Access Token

```http theme={"dark"}
GET /v1/secrets/:id/oauth2/token
```

For OAuth2-type secrets, returns the current access token. If the token has expired, KnoxCall will automatically refresh it before returning.

### Path Parameters

| Parameter | Type | Description                                   |
| --------- | ---- | --------------------------------------------- |
| `id`      | uuid | The secret ID (must be an OAuth2-type secret) |

### Query Parameters

| Parameter     | Type   | Default          | Description                   |
| ------------- | ------ | ---------------- | ----------------------------- |
| `environment` | string | Base environment | Target a specific environment |

### Response

```json theme={"dark"}
{
  "data": {
    "access_token": "eyJhbGciOiJSUzI1NiIs...",
    "expires_at": "2026-03-10T15:30:00.000Z",
    "token_type": "Bearer",
    "connection_status": "connected"
  },
  "meta": { "request_id": "550e8400-e29b-41d4-a716-446655440000" }
}
```

### Errors

| Status | Type           | Description                                    |
| ------ | -------------- | ---------------------------------------------- |
| 400    | `invalid_type` | Secret is not an OAuth2 type                   |
| 404    | `not_found`    | Secret not found                               |
| 500    | `token_error`  | Failed to retrieve or refresh the OAuth2 token |
