Official Python SDKs for Asgardeo - WSO2's Identity and Access Management platform.
This repository contains two complementary Python packages:
Core Python SDK for Asgardeo authentication flows.
pip install asgardeo
Features:
- ✅ Native authentication flows (no browser redirects)
- ✅ Token management (exchange, refresh)
- ✅ Full async/await support
- ✅ Automatic resource cleanup
- ✅ Type hints and error handling
AI agent authentication and on-behalf-of (OBO) token flows.
⚠️ WARNING: Asgardeo AI SDK is currently under development, is not intended for production use, and therefore has no official support.
pip install asgardeo-ai
Features:
- ✅ AI agent authentication
- ✅ On-behalf-of (OBO) token flows
- ✅ User authorization URL generation
- ✅ Built on top of core asgardeo SDK
from asgardeo import AsgardeoConfig, AsgardeoNativeAuthClient
config = AsgardeoConfig(
base_url="https://api.asgardeo.io/t/your-org",
client_id="your_client_id",
redirect_uri="your_redirect_uri",
client_secret="your_client_secret"
)
async with AsgardeoNativeAuthClient(config) as client:
# Authenticate user
await client.authenticate()
await client.authenticate(
authenticator_id="BasicAuthenticator",
params={"username": "user@example.com", "password": "password"}
)
# Get tokens
if client.flow_status == "SUCCESS_COMPLETED":
tokens = await client.get_tokens()
print(f"Access Token: {tokens.access_token}")
from asgardeo import AsgardeoConfig
from asgardeo_ai import AgentAuthManager, AgentConfig
config = AsgardeoConfig(
base_url="https://api.asgardeo.io/t/your-org",
client_id="your_client_id",
redirect_uri="https://your-app.com/callback",
client_secret="your_client_secret"
)
agent_config = AgentConfig(
agent_id="your_agent_id",
agent_secret="your_agent_secret"
)
async with AgentAuthManager(config, agent_config) as auth_manager:
# Get agent token
agent_token = await auth_manager.get_agent_token(["openid", "profile"])
# Generate user authorization URL
auth_url, state = auth_manager.get_authorization_url(["openid", "email"])
# Exchange auth code for user token (OBO flow)
user_token = await auth_manager.get_obo_token(auth_code, agent_token=agent_token)
- Core SDK Guide - Native authentication flows
- AI SDK Guide - Agent authentication and OBO flows
- Examples - Complete working examples
- Publishing Guide - Release and deployment process
The examples/
directory contains practical examples:
- native_auth.py - Step-by-step authentication flow
- agent_auth.py - Basic AI agent authentication
- obo_flow.py - Interactive OBO token flow
- Python 3.10+
- Poetry for dependency management
# Clone repository
git clone https://github.com/asgardeo/python.git
cd python
# Install core SDK
cd packages/asgardeo
poetry install
# Install AI SDK
cd ../asgardeo-ai
poetry install
# Build core SDK
cd packages/asgardeo
poetry build
# Build AI SDK
cd ../asgardeo-ai
poetry build
# Test core SDK example
python examples/asgardeo/native_auth.py
# Test AI SDK examples
python examples/asgardeo-ai/agent_auth.py
python examples/asgardeo-ai/obo_flow.py
- Python 3.10+ - Modern async/await features
- Asgardeo Account - Sign up at asgardeo.io