Skip to main content

Generate Modo Authentication

Project description

modo2auth-py

A Python package to generate authentication details to communicate with Modo servers

Prerequesites

Credentials that are created and shared by Modo. These will be different for each environment (int, prod, local etc...).

  • api_identifier - API key from Modo
  • api_secret - API secret from Modo

These values will be used when intantiating the library.

python - See docs

Install

Via pip

pip install modo2auth requests

Via pipenv

pipenv install modo2auth

Example Usage

Here's an example using TBD to make requests. You can use your preferred method or library.

Note: if installed with pipenv, run shell commands via pipenv shell

GET Example

# 1. IMPORT
import requests
import modo2auth

# 2. INSTANTIATE
# get from Modo
creds = {
    "api_identifier": "...",
    "api_secret":  "..."
}
headers = {
    "Content-Type": "application/json"
}
api_host = "http://localhost:82"  # TODO: replace with stable testing env endpoint
api_uri = "/v2/vault/public_key"

# 3. SEND REQUEST
response = requests.get(
    api_host+api_uri,
    headers=headers,
    auth=modo2auth.Sign(creds['api_identifier'], creds['api_secret'], api_uri))

print(response.text)

POST Example

# 1. IMPORT
import requests
import modo2auth

# 2. INSTANTIATE
# get from Modo
creds = {
    "api_identifier": "...",
    "api_secret":  "..."
}
headers = {
    "Content-Type": "application/json"
}
api_host = "http://localhost:82"  # TODO: replace with stable testing env endpoint
api_uri = "/v2/reports"
data = '{"start_date": "2020-05-22T00:00:00Z","end_date": "2020-05-26T00:00:00Z"}'

# 3. SEND REQUEST
response = requests.post(
    api_host+api_uri,
    headers=headers,
    data=data,
    auth=modo2auth.Sign(creds['api_identifier'], creds['api_secret'], api_uri))

print(response.text)

API

Sign(api_identifier, api_secret, api_uri)

Returns an instance of the Sign class. Intended for use with the requests package.

  • api_identifier (string) - API key from Modo
  • api_secret (string) - API secret from Modo
  • api_uri (string) - Api Uri intending to call to (ex: "/v2/vault/public_key")

Contributing

  1. Fork this repo via Github
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Ensure unit tests are passing (none at the moment...)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin feature/my-new-feature)
  6. Create new Pull Request via Github

Development

In the root of the project:

# enter the virtual environment
pipenv shell

# ...develop away :)

Publishing

Prerequisites:

  1. User account on https://pypi.org/
  2. User with Access to https://pypi.org/project/modo2auth/1.0.0/
# install these globally
pip3 install setuptools twine wheel

Build and release:

  1. Edit version in setup.py
  2. Build release package: python3 setup.py sdist bdist_wheel
  3. Upload: twine upload dist/*
  4. Tag with new version git tag v1.1.0 (According to Semantec Versioning guidelines)
  5. Push tags git push --tags

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

modo2auth-1.2.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

modo2auth-1.2.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file modo2auth-1.2.1.tar.gz.

File metadata

  • Download URL: modo2auth-1.2.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1

File hashes

Hashes for modo2auth-1.2.1.tar.gz
Algorithm Hash digest
SHA256 ca15cc0f781f44fb97ae59b9f5ec7dc403fa99520baad8b30f41ee3551acb481
MD5 cba8588fcbdca10258bd8cfb701b7daa
BLAKE2b-256 8b84c94e44f81bb5f7526a64eb6eb7021e67cc8ef58d90ebc885d181af1a233d

See more details on using hashes here.

File details

Details for the file modo2auth-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: modo2auth-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1

File hashes

Hashes for modo2auth-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 267c49a51a7207658fc16ba8396af0650890946a126f3a2892297b7097549efe
MD5 3569dc91ee3a9e5490ab099e05576c31
BLAKE2b-256 5b1e3c065445de74a095ff9fae4cafba270bb443e32a18d52e8a04aae427a606

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