Oceana API library to manage authentication token and headers
Project description
oceana_token
Oceana API library to manage authentication token and headers
Setup
Install latest version
pip install oceana_token
Usage
Create authentication headers:
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:
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:
# 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
# Using build package
python -m build
Run tests
# 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
# Reinstall avoiding reinstalling dependencies
pip install --upgrade --no-deps --force-reinstall dist\oceana_token-0.0.5-py3-none-any.whl
# Reinstall with dependencies
pip install dist\oceana_token-0.0.5-py3-none-any.whl --force-reinstall
Check style guide enforcement
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oceana_token-0.0.5.tar.gz.
File metadata
- Download URL: oceana_token-0.0.5.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a10e733fd73a45946ecf9fcb366d60528c81f342ce0adbfdb8515627ffa81146
|
|
| MD5 |
516f8612d5efa635af12ff20afc064d8
|
|
| BLAKE2b-256 |
4cee78bcfbac75ff89ccd7986603dea42f55d2ff157fd906cd87a408645cbe5a
|
File details
Details for the file oceana_token-0.0.5-py3-none-any.whl.
File metadata
- Download URL: oceana_token-0.0.5-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d0342412d8787f844faca9c8b1318918742ed2d1ad68fe1bed9a8d0df94039a
|
|
| MD5 |
3e6d4b9ad956f2d3f3fdc04f64ec370c
|
|
| BLAKE2b-256 |
7dc3a92a74fd2fcabe17e268268b3dc5fd3ee750eb4a277bf041f57e3caf0be5
|