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 session:
from ezsession import get_session
def datto_rmm_session(api_key, api_secret, server):
base_uri = f"https://{server}-api.centrastage.net"
auth = {
"type": "oauth_basic",
"auth_uri": f"{base_uri}/auth/oauth/token",
"username": api_key,
"password": api_secret,
"server": server,
}
return get_session(auth), base_uri
Example to initialize a Datto RMM session then get account variables.
drmm_user = "Your Datto RMM API Key"
drmm_pass = "Your Datto RMM API Secret"
drmm_server = "merlot" # Change to your Datto RMM server.
session, base_uri = datto_rmm_auth(drmm_user, drmm_pass, drmm_server)
response = session.get(f"{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.4.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for ezsession-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db90fa4550acd0d1838b2f17d3b9108d63142549a3b38a96eaf1dad597b91b83 |
|
MD5 | d0170ca73d175a56ab7e32150eaaf676 |
|
BLAKE2b-256 | ecc5204894145e6aa74b1816276bc7c6a10acbff45109df1dc0584ab04f3e4d6 |