Oceana API library to manage authentication token and headers
Project description
oceana_token
Oceana API library to manage authentication token and headers
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")
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=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_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.2-py3-none-any.whl
# Reinstall with dependencies
pip install dist\oceana_token-0.0.2-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 |
---|---|
build | 1.2.1 |
setuptools | 67.8.0 |
wheel | 0.38.4 |
requests | 2.29.0 |
pytest | 7.4.0 |
coverage | 6.4.4 |
flake8 | 4.0.1 |
python-decouple | 3.8 |
typing-extensions | 4.12.2 |
Releases
Version 0.0.2:
- First version
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
oceana_token-0.0.2.tar.gz
(7.1 kB
view details)
Built Distribution
File details
Details for the file oceana_token-0.0.2.tar.gz
.
File metadata
- Download URL: oceana_token-0.0.2.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52c9326e01ad5083ce76ffbef06f08173a564c4afd89e291ed117da2271d753d |
|
MD5 | b38b534252ddf878447d805d9d10b961 |
|
BLAKE2b-256 | 577545b72c844bdeac398329d9ad343c7d20c732d6de5f51daee63a626fa2e66 |
File details
Details for the file oceana_token-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: oceana_token-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a42f048e2d29fbbbf728ee4a1c9fe26374d4d9e4682bd840b44387c705e7c3a8 |
|
MD5 | e3c471c479791a4ecf9df67df27f2ced |
|
BLAKE2b-256 | bbe73755b43cda20775f316a187fbd67fa2e001727496d44db4ab8bf9ad1ccb5 |