A small useful Python module to abstract away the common auth header methods used by different software vendors. The output is a requests session with the authentication headers built in.
Project description
ezsession
A small useful Python module to abstract away the common auth header methods used by different software vendors. The output is a requests session with the authentication headers built in.
pip install ezsession
Auth Types and Required Inputs
- oauth -
auth_uri
,client_id
,client_secret
,audience
- oauth_basic -
auth_uri
,username
,password
- oauth_password -
auth_uri
,username
,password
- basic -
username
,password
,auth_uri
(optional) - bearer -
api_key
- ApiToken -
api_key
- dell -
auth_uri
,client_id
,client_secret
Examples
Example usage for getting a Datto RMM or Huntress session:
from ezsession import get_session
def datto_rmm_auth(api_key, api_secret):
auth = {
"type": "oauth_basic",
"auth_uri": f"{base_uri}/auth/oauth/token",
"username": api_key,
"password": api_secret,
"server": "concord",
}
return get_session(auth)
def huntress_auth(api_key, api_secret):
auth = {
"type": "basic",
"username": auth_data["api_key"],
"password": auth_data["api_secret"],
}
return get_session(auth)
Example to initialize a Datto RMM session then get account variables.
server = "merlot" # Change to your Datto RMM server.
base_uri = f"https://{server}-api.centrastage.net"
session = datto_rmm_auth(drmm_user, drmm_pass)
response = session.get(f"https://{base_uri}/api/v2/account/variables")
variables = response.json()["variables"]
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
ezsession-0.0.2.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for ezsession-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcf68fe02cfbd7a886c1d45796a1cfddf86eefa8431260e6918f5e84eaaa776b |
|
MD5 | e82ccec12d42456b59754328aef943c9 |
|
BLAKE2b-256 | 84e4cd1d1d698838428b4ba3aed1f426ba6d262dce098e3ec35a26fdb591bedb |