Metadata-Version: 2.4
Name: eduzz-miau-client
Version: 1.4.2
Summary: Eduzz Miau Client for Python
Author-email: Eduzz <dev@eduzz.com>
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: pyjwt>=2.8
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.22; extra == 'dev'
Description-Content-Type: text/markdown

# eduzz-miau-client

Python client for the Eduzz Miau authentication service.

## Installation

```bash
pip install eduzz-miau-client
```

## Usage

```python
from eduzz_miau_client import MiauClient

client = MiauClient(
    api_url="https://your-miau-api-url",
    app_secret="your-app-secret",
)

token = client.get_token()
```

Or using a context manager:

```python
with MiauClient(api_url="https://your-miau-api-url", app_secret="your-app-secret") as client:
    token = client.get_token()
```

## Example

```python
import httpx
import json
import os
from eduzz_miau_client import MiauClient

MIAU_API_URL = os.environ.get('MIAU_API_URL')
MIAU_APP_SECRET = os.environ.get('MIAU_APP_SECRET', '')
YOUR_API_URL = os.environ.get('YOUR_API_URL', 'https://your-api.example.com')

client = MiauClient(api_url=MIAU_API_URL, app_secret=MIAU_APP_SECRET)
token = client.get_token()

http = httpx.Client()
response = http.get(YOUR_API_URL+'/your/endpoint', headers={'Authorization': f'Bearer {token}'})
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
```

## API

### `MiauClient(api_url, app_secret)`

Creates a new client instance.

| Parameter    | Type  | Description                  |
|-------------|-------|------------------------------|
| `api_url`   | `str` | Miau API base URL            |
| `app_secret`| `str` | Application secret from Miau |

### `client.get_token() -> str`

Returns a valid JWT access token. Tokens are cached in memory and automatically refreshed when they are within 60 seconds of expiration.

### `client.close()`

Closes the underlying HTTP client. Called automatically when using the context manager.

## Requirements

- Python >= 3.10
