Generate Modo Authentication
Reason this release was yanked:
bad one
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 Modoapi_secret
- API secret from Modo
These values will be used when intantiating the library.
python
- See docs
Install
Via pipenv
pipenv install modo2auth
Via pip
pip install modo2auth requests
Copy/Paste
- Copy
modo2auth/modo2auth.py
to your project. - Install required dependencies:
# for dependencies sudo easy_install pip # for requests sudo pip install requests
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 Modoapi_secret
(string) - API secret from Modoapi_uri
(string) - Api Uri intending to call to (ex:"/v2/vault/public_key"
)
Contributing
- Fork this repo via Github
- Create your feature branch (
git checkout -b feature/my-new-feature
) - Ensure unit tests are passing (none at the moment...)
- Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin feature/my-new-feature
) - Create new Pull Request via Github
Development
In the root of the project:
# enter the virtual environment
pipenv shell
# ...develop away :)
Publishing
Prerequisites:
- User account on https://pypi.org/
- User with Access to https://pypi.org/project/modo2auth/1.0.0/
# install these globally
pip3 install setuptools twine wheel
Build and release:
- Edit version in
setup.py
- Build release package:
python3 setup.py sdist bdist_wheel
- Upload:
twine upload dist/*
- Tag with new version
git tag v1.1.0
(According to Semantec Versioning guidelines) - Push tags
git push --tags
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
Built Distribution
Hashes for modo2auth-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36c3b28d6a6de8d318951d19b646226affca29e77ec41112bb7d3559a0c7f9a2 |
|
MD5 | b57a4cf56deeb8d23e7147dffbdacd5b |
|
BLAKE2b-256 | 666fd58c388582d4e2cf8d115015fab24736d563af2cd9edf8334a858fd7048d |