Skip to main content

Python SDK for GreenAuth authentication service

Project description

GreenAuth Python SDK

PyPI version Python versions License

Official Python SDK for the GreenAuth authentication service.

Installation

pip install greenauth

Quick Start

import asyncio
from greenauth import GreenAuthAPI

async def main():
    # Initialize with your API key
    api = GreenAuthAPI(api_key="your_api_key_here")
    
    # Register a new user
    result = await api.auth.register(
        username="testuser",
        password="SecurePass123!",
        license_key="GA-XXXX-XXXX-XXXX",
        hwid="device_hash_here",
        app_id="your_app_id",
        app_name="Your App Name"
    )
    print("Registration result:", result)
    
    # Login user
    login_result = await api.auth.login(
        username="testuser",
        password="SecurePass123!",
        hwid="device_hash_here",
        app_id="your_app_id",
        app_name="Your App Name"
    )
    print("Login result:", login_result)

asyncio.run(main())

API Handlers

Authentication

# Register user
await api.auth.register(username, password, license_key, hwid, app_id, app_name)

# Login user
await api.auth.login(username, password, hwid, app_id, app_name)

Applications

# List all apps
apps = await api.apps.get_apps()

# Create new app
app = await api.apps.create_app("My App", description="My description")

# Get app details
details = await api.apps.get_app_details(app_id)

# Reset HWID
await api.apps.reset_hwid(app_id, username, password, license_key)

Licenses

# Create license
license = await api.licenses.create_license(app_id, days=30, max_hwids=3)

# Delete unused licenses
await api.licenses.delete_unused(app_id)

Users

# Disable user
await api.users.disable_user(app_id, username)

# Enable user
await api.users.enable_user(app_id, username)

Security

# Ban HWID
await api.security.ban_hwid(app_id, hwid)

# Unban HWID
await api.security.unban_hwid(app_id, hwid)

# Ban IP
await api.security.ban_ip(app_id, ip_address)

# Unban IP
await api.security.unban_ip(app_id, ip_address)

Webhooks

# Create webhook
webhook = await api.webhooks.create_webhook(
    app_id, 
    "https://your-webhook-url.com",
    events=["user.login", "user.register"],
    secret="webhook_secret"
)

# List webhooks
webhooks = await api.webhooks.list_webhooks(app_id)

# Delete webhook
await api.webhooks.delete_webhook(app_id, webhook_id)

Configuration

You can configure the SDK in multiple ways:

# Method 1: Direct parameters
api = GreenAuthAPI(
    server_url="https://greenauth.co.uk",
    api_key="your_api_key"
)

# Method 2: Environment variables
import os
os.environ["GREENAUTH_SERVER"] = "https://greenauth.co.uk"
os.environ["GREENAUTH_API_KEY"] = "your_api_key"

api = GreenAuthAPI()  # Will use environment variables

Error Handling

The SDK raises RuntimeError for API errors:

try:
    await api.auth.login("user", "pass", "hwid", "app_id", "app_name")
except RuntimeError as e:
    print(f"Authentication failed: {e}")

Advanced Usage

Using Custom Client

from greenauth import APIClient, AuthHandler

client = APIClient(server_url="https://your-server.com", api_key="your_key")
auth = AuthHandler(client)
result = await auth.register(...)

Individual Handlers

from greenauth import AppsHandler, APIClient

client = APIClient(api_key="your_key")
apps = AppsHandler(client)
app_list = await apps.get_apps()

License

This project is licensed under the GNU General Public License - see the LICENSE file for details.

Support

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greenauth-1.0.0.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

greenauth-1.0.0-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file greenauth-1.0.0.tar.gz.

File metadata

  • Download URL: greenauth-1.0.0.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for greenauth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f50c6a44fa9f42dc15dbfc375b2313388b5c6140e140aa36fe9fa88a7d62b328
MD5 08b383b8a85b1a98465d3682836803f6
BLAKE2b-256 f0c04ebad3ea7c137747b79d86e3936498665e5aa5020fd41a6e14fe6cced349

See more details on using hashes here.

File details

Details for the file greenauth-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: greenauth-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for greenauth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b60658aa3fdfdfeda8cd16cff29e8cb945753f27755f37da0bb089bb02f73979
MD5 d1d8dc903bc212d09c8414b891ca0825
BLAKE2b-256 7fb68f9a201a05d92a174b62cd0c60469f23a177304f40799b2dbacf7679f9c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page