No description
  • Rust 78.5%
  • Python 16.9%
  • Shell 4.6%
Find a file
vBlackOut f6143b2def
Some checks failed
Python application / build-run (push) Failing after 2s
Actualiser README.md
2026-04-19 08:04:43 +02:00
.github/workflows # Ceci est la combinaison de 2 commits. 2025-07-08 18:33:15 +02:00
example Add method get/post 2025-07-10 14:56:33 +02:00
images Update cli ppauth 2025-07-13 23:19:35 +02:00
src Update cli ppauth 2025-07-13 23:19:35 +02:00
tests # Ceci est la combinaison de 2 commits. 2025-07-08 18:33:15 +02:00
.gitignore Add method get/post 2025-07-10 14:56:33 +02:00
.python-version Add build.sh 2025-07-08 19:53:35 +02:00
build.sh Add totp method version 0.1.7 2025-07-11 19:07:07 +02:00
Cargo.lock Add totp method version 0.1.7 2025-07-11 19:07:07 +02:00
Cargo.toml Add totp method version 0.1.7 2025-07-11 19:07:07 +02:00
pyproject.toml Update cli ppauth 2025-07-13 23:19:35 +02:00
README.md Actualiser README.md 2026-04-19 08:04:43 +02:00
setup.py Add totp method version 0.1.7 2025-07-11 19:07:07 +02:00

PyProxyAuth



A lightweight Python library to authenticate and retrieve tokens via ProxyAuth.

install

pip install ppauth

usage

import ppauth

ppauth.auth(
    host="127.0.0.1", port=8080,
    username="admin", password="admin123",
    
    # Optional TOTP code (used if two-factor authentication is enabled).
    # Note: If using TOTP, the server should issue a token with a minimum 1-day expiration.
    # As a developer, you should provide a new TOTP code each time the token expires.
    totp="56845",
    
    timezone="Europe/Paris" 
)

token = ppauth.token()
token = ppauth.token(renew=True) # Automatically re-authenticates and returns a new token if the previous one has expired.
lease_token = ppauth.lease_token()

print({"token": token, "expire_at": lease_token})

# result
# {"expire_at": 16500,"token":"ZoHAauGmCyxjq6+1sfVbqy..."}

# for easy use method GET
# Use the route defined in routes.yml within your backend delivery. 
# You don't need to manually include the token in the headers it's handled automatically
headers = {"user-agent": "ppauth/0.1.1"}
params = {"params_key": "my_send_request_params_via_get"}

ppauth.get(
    "/app",          # The API route (relative path) to call on the authenticated backend
    headers=headers, # Optional custom HTTP headers (Python dict), e.g. {"X-User": "admin"}
    params=params,   # Optional query parameters (Python dict), e.g. {"limit": "10"}
    verify=False,    # Disable TLS certificate verification (useful for self-signed certs)
    timeout=5,       # Max duration (in seconds) to wait for a response before failing
    retry=5          # Number of retry attempts if the request fails (timeout or server error)
)

# result
# 'ok'

# you are similar for POST method
headers = {"user-agent": "ppauth/0.1.1"}
body = {"body_key": "my_send_request_data_via_post"}
json = {"json_key": "my_send_request_json_data_via_post"}

ppauth.post(
    "/app",          # The API route (relative path) to call on the authenticated backend
    headers=headers, # Optional custom HTTP headers (Python dict), e.g. {"Content-Type": "application/json"}
    body=body,       # (If implemented) Optional raw body content (usually a string or bytes)
    json=json,       # Optional JSON body (Python dict) that will be serialized and sent as application/json
    timeout=5,       # Max duration (in seconds) to wait for a response before raising a timeout error
    verify=False,    # Disable TLS certificate verification (useful for self-signed certificates)
    retry=2          # Number of retry attempts if the request fails (e.g., timeout or 5xx server errors)
)

# result
# 'ok'

Last Versions

Show All Versions