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")
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.3-py3-none-any.whl
# Reinstall with dependencies
pip install dist\oceana_token-0.0.3-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.3:
- 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.3.tar.gz
(7.3 kB
view details)
Built Distribution
File details
Details for the file oceana_token-0.0.3.tar.gz
.
File metadata
- Download URL: oceana_token-0.0.3.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d366fd04c498a7142b6c0121ad5e9656254f5dbd2fe6361fd19ae87c8502ee3 |
|
MD5 | 5cc7d43c44eb8a2b4712fb3c025442e6 |
|
BLAKE2b-256 | b0263f435f3ca8c14b13b9d8c080f0c9959327b069f84ae7963b9adae9f43c6d |
File details
Details for the file oceana_token-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: oceana_token-0.0.3-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 | cbe18a2d80aaf62463576121225d1df8349bee0c4307eb636cbc97ef3f8563a4 |
|
MD5 | c5cde38c518025a55984b67f87420be8 |
|
BLAKE2b-256 | d129b4abaa3a999851f8d3a90b888aac54b8aff3423e3b822b194b583b026344 |