Python SDK for GreenAuth authentication service
Project description
GreenAuth Python SDK
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
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
greenauth-1.0.1.tar.gz
(45.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
greenauth-1.0.1-py3-none-any.whl
(33.1 kB
view details)
File details
Details for the file greenauth-1.0.1.tar.gz.
File metadata
- Download URL: greenauth-1.0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a46c49bd53c0c08bd0bca08e738f3fa2526c174c3cd013d1ef83507487518feb
|
|
| MD5 |
9ef414df3eed3cd91576a9dcab177535
|
|
| BLAKE2b-256 |
25cd33b711130509f6d12c7a22bfaef6d083aaf0e3d46dcbe62ff19ae614092e
|
File details
Details for the file greenauth-1.0.1-py3-none-any.whl.
File metadata
- Download URL: greenauth-1.0.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
beeaea92f27dfdd86f8f04ba51eac6dd7d8700f11928c1216ec951ad1e5df6ae
|
|
| MD5 |
b74c38e69d511390fd738d1667defb00
|
|
| BLAKE2b-256 |
9cfb48a0abd0e986a9492c3d5e79d3da63e9dfb290d524434f759b87f491d491
|