Metadata-Version: 2.4
Name: oceana_token
Version: 0.0.5
Summary: Oceana API library to manage authentication token and headers
Author: jorgegilramos
License-Expression: MIT
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: python-decouple==3.8
Dynamic: author

# oceana_token
Oceana API library to manage authentication token and headers


## Setup

Install latest version
```shell
pip install oceana_token
```

## Usage

Create authentication headers:
```python
from oceana_token import *
import json

# Authentication in Oceana API
oceana_api_client = Authenticate(url="http://127.0.0.1:5000",
                                 client_id="oceana-api-client",
                                 client_secret="bad_password",
                                 api_version="v1")
token = oceana_api_client.get_token()

# Create headers
headers = oceana_api_client.headers(headers={})

# Add authentication header
headers = oceana_api_client.authorization_header(headers={})

# Create headers from template
headers = json.loads(oceana_api_auth_header.format(token=f"Bearer {oceana_api_client.get_token()}"))
```

Request an endpoint:
```python
import requests

headers = ...

response = requests.get(url="http://127.0.0.1:5000/v1/organization/id/1", headers=headers, verify=False)
```

## Environment

Properties in environment variables:
```shell
# Example
OCEANA_API_URL="http://127.0.0.1:5000"
OCEANA_API_CLIENT_ID="oceana-api-client"
OCEANA_API_CLIENT_SECRET="bad_password"
OCEANA_API_VERSION="v1"
OCEANA_API_LOGGER_LEVEL="DEBUG"
OCEANA_API_LOGGER_FORMAT="%(asctime)s - [%(name)-25s] - %(levelname)-5s - %(message)s"
```

## Packaging

Build package
```shell
# Using build package
python -m build
```


Run tests
```shell
# All tests
pytest -q -rP

# Partial tests
pytest tests/unit/test_authentication.py -v -rP
pytest tests/unit/test_header.py -v -rP
pytest tests/unit/test_jwt.py -v -rP
```

```shell
# Reinstall avoiding reinstalling dependencies
pip install --upgrade --no-deps --force-reinstall dist\oceana_token-0.0.5-py3-none-any.whl
```

```shell
# Reinstall with dependencies
pip install dist\oceana_token-0.0.5-py3-none-any.whl --force-reinstall
```

Check style guide enforcement
```shell
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
```

## Dependencies

| Library                | Version   |
|------------------------|-----------|
| requests               | >= 2.29.0 |
| python-decouple        | == 3.8    |



## Releases
**Version 0.0.5**:
   - Python upgraded ["3.9", "3.10", "3.11"] -> ["3.12", "3.13", "3.14"]
   - Upgrading libraries dependencies
**Version 0.0.4**:
   - Added configurable API version
**Version 0.0.3**:
   - First version
