Skip to main content

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.4-py3-none-any.whl
# Reinstall with dependencies
pip install dist\oceana_token-0.0.4-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.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

oceana_token-0.0.4.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oceana_token-0.0.4-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file oceana_token-0.0.4.tar.gz.

File metadata

  • Download URL: oceana_token-0.0.4.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.20

File hashes

Hashes for oceana_token-0.0.4.tar.gz
Algorithm Hash digest
SHA256 009bc67d048a8ba64913d8ba2427af0ba94e076c7060411e341ff4c27be41a36
MD5 3bddbed1b1e7d1440c730f46de3c854a
BLAKE2b-256 ee30f937401f4ba3359fc2d6e2895f2b2f55963781586b95f0cc9b30a45ab17e

See more details on using hashes here.

File details

Details for the file oceana_token-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: oceana_token-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.20

File hashes

Hashes for oceana_token-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 464ebee8873ee781636f878f9e29e79de58ddc8cc6c7ea5615885976d0b7f18a
MD5 a015e21434922752f418cb7bd6a74184
BLAKE2b-256 520e47e06f1109d33df002dac10254896f5d5747937cb7c9f00491b826ca717d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page