| examples/ plain | 17 hours ago | ||
| src/ gnexus_gauth | 17 hours ago | ||
| tests/ unit | 17 hours ago | ||
| .gitignore | 17 hours ago | ||
| README.md | 17 hours ago | ||
| pyproject.toml | 17 hours ago | ||
Framework-agnostic Python client library for integrating services with gnexus-auth.
Alpha — early scaffold with working core pieces.
Current scaffold includes:
GAuthClient;httpxpip install gnexus-gauth
Or from source:
pip install git+https://git.gnexus.space/git/root/gnexus-auth-client-py.git
The package is designed around one high-level client:
from gnexus_gauth.client import GAuthClient
It expects:
GAuthConfigfrom gnexus_gauth.client import GAuthClient
from gnexus_gauth.config import GAuthConfig
from gnexus_gauth.oauth import HttpTokenEndpoint
from gnexus_gauth.runtime import HttpRuntimeUserProvider
from gnexus_gauth.webhook import HmacWebhookVerifier, JsonWebhookParser
from gnexus_gauth.support import InMemoryStateStore, InMemoryPkceStore
config = GAuthConfig(
base_url="https://gnexus-auth.local",
client_id="my-service",
client_secret="my-secret",
redirect_uri="https://my-service.local/callback",
)
client = GAuthClient(
config=config,
token_endpoint=HttpTokenEndpoint(config),
runtime_user_provider=HttpRuntimeUserProvider(config),
webhook_verifier=HmacWebhookVerifier(config),
webhook_parser=JsonWebhookParser(),
state_store=InMemoryStateStore(),
pkce_store=InMemoryPkceStore(),
)
# Build authorization URL
auth_request = client.build_authorization_request(
return_to="/dashboard",
scopes=["openid", "email", "profile"],
)
print(auth_request.authorization_url)
# Exchange callback code
token_set = client.exchange_authorization_code("code_from_callback", "state_from_callback")
user = client.fetch_user(token_set.access_token)
# Verify and parse webhook
event = client.verify_and_parse_webhook(raw_body, headers, "webhook_secret")
See examples/plain/example.py for a more complete demonstration.
src/gnexus_gauth/ __init__.py client.py # GAuthClient config.py # GAuthConfig contracts.py # Abstract interfaces dto.py # Data transfer objects exceptions.py # Exception hierarchy oauth.py # PKCE, URL builder, token endpoint runtime.py # Userinfo client support.py # In-memory stores, system clock webhook.py # HMAC verifier, JSON parser
# Install with dev dependencies pip install -e ".[dev]" # Run tests pytest # Run linter ruff check src tests # Run type checker mypy src
gnexus/auth-clientgnexus-auth