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.
Auth Types and Required Inputs
- oauth -
client_id
,client_secret
,audience
- oauth_basic -
username
,password
- oauth_password -
username
,password
- basic -
username
,password
- bearer -
api_key
- ApiToken -
api_key
- dell -
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.1.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for ezsession-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4db8db0ad1227d18f75ae45c4849ae683a185ad7470e24209c236bdf173f806e |
|
MD5 | 2543090fdf96165609909dd5195f749a |
|
BLAKE2b-256 | fc6bd0231f8bbddfe8d236a75f10dc93ec1f7b2fadcbc635e94cd4494bf432da |