Asgardeo AI SDK
⚠️ WARNING: Asgardeo AI SDK is currently under development, is not intended for production use, and therefore has no official support.
Python SDK for Asgardeo AI agent authentication and on-behalf-of (OBO) token flows.
Features
- Agent Authentication: Authenticate AI agents using agent credentials
- On-Behalf-Of (OBO) Tokens: Get user tokens on behalf of authenticated agents
- Async/Await Support: Full async implementation using httpx
- Token Management: Handle token exchange, refresh, and revocation
- Authorization URLs: Generate authorization URLs for user authentication flows
Installation
Install from local development:
pip install -e .
Quick Start
Basic Setup
import asyncio
from asgardeo import AsgardeoConfig
from asgardeo_ai import AgentAuthManager, AgentConfig
# Configure Asgardeo connection
config = AsgardeoConfig(
base_url="https://api.asgardeo.io/t/your-organization",
client_id="your_client_id",
redirect_uri="https://your-app.com/callback",
client_secret="your_client_secret"
)
# Configure AI agent
agent_config = AgentConfig(
agent_id="your_agent_id",
agent_secret="your_agent_secret"
)
# Create auth manager
auth_manager = AgentAuthManager(config, agent_config)
Agent Authentication
async def main():
async with AgentAuthManager(config, agent_config) as auth_manager:
# Get token for the AI agent
agent_token = await auth_manager.get_agent_token(["openid", "profile"])
print(f"Agent access token: {agent_token.access_token}")
asyncio.run(main())
User Authorization Flow
async def user_auth_flow():
async with AgentAuthManager(config, agent_config) as auth_manager:
# Generate authorization URL for user
scopes = ["openid", "profile", "email"]
auth_url, state = auth_manager.get_authorization_url(scopes)
print(f"Redirect user to: {auth_url}")
# After user authorizes and you receive the auth code:
# auth_code = "received_from_callback"
# Get OBO token for the user
obo_token = await auth_manager.get_obo_token(auth_code, scopes, agent_token)
# print(f"User access token: {obo_token.access_token}")
API Reference
AgentAuthManager
Main class for handling agent authentication and OBO flows.
Methods
get_agent_token(scopes: Optional[List[str]] = None) -> OAuthToken: Get access token for the agentget_authorization_url(scopes: List[str], state: Optional[str] = None) -> Tuple[str, str]: Generate authorization URLget_obo_token(auth_code: str, agent_token: str, scopes: Optional[List[str]] = None) -> OAuthToken: Exchange auth code for user token
AgentConfig
Configuration for AI agent credentials.
agent_id: str: Agent identifieragent_secret: str: Agent secret
Requirements
- Python >= 3.10
httpx(for async HTTP)asgardeo(base SDK)
Development
# Install dependencies
poetry install
# Build
poetry build
Metadata
Release files for asgardeo_ai 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asgardeo_ai-0.2.4.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asgardeo_ai-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / asgardeo_ai-0.2.4.tar.gz
| Download URL | asgardeo_ai-0.2.4.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8ed463feb30588d53f2cb56ba6440ccfa61237fe2295b20ca65360c7e2874af
|
|
BLAKE2b-256 checksum How to use checksums |
42567b57b2bb80b11f53ff7236f52f52a18ea2de6de18ee73610e0960b536ee7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.10.20 Linux/6.17.0-1010-azure
|
Release files / asgardeo_ai-0.2.4-py3-none-any.whl
| Download URL | asgardeo_ai-0.2.4-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90c719a52be54c1df29c3535f1e63e690ba8dfd063f04ac744c79f663afb3151
|
|
BLAKE2b-256 checksum How to use checksums |
25a68a893f48448f1196eb94b2d454010f202353b7525b0f286b8043c5a95643
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.10.20 Linux/6.17.0-1010-azure
|