Python SDK
Source and runnable examples are in the aep-python GitHub repository. The agent-enrollment-protocol distribution is published on PyPI. AEP integration does not require an InFlow account.
Install the distribution and select a role
Python 3.11 or newer is required. One installation provides the role modules and the ASGI adapter; there are no separate Agent, Service, or Platform distributions to install. The core module is synchronous and transport-independent. Agent, Service, and Platform operations are asynchronous and integrate with application-owned storage and security policy.
python -m pip install agent-enrollment-protocol
| Module | Use it for |
|---|---|
| agent_enrollment_protocol.core | Protocol models, validation, identity, and assertion primitives. |
| agent_enrollment_protocol.agent | Inspect, Enroll, Status, Grant, Revoke, credential management, and protected-resource authentication as an Agent. |
| agent_enrollment_protocol.service | AEP command handling, enrollment policy, credential issuance, and request authentication at a Service. |
| agent_enrollment_protocol.adapters | Expose a Service and protect application routes through framework-neutral ASGI. |
| agent_enrollment_protocol.platform | Optional hosted Agent identity provisioning, delegated signing, and lifecycle operations. |
Give an Agent an identity and a Service session
An Agent needs a Service-scoped identity provider before it can sign Enroll, Status, Grant, or Revoke requests. Agent and AgentOptions accept that provider and application-owned stores. Use the asynchronous Service session to read Inspect before collecting Claims, enroll the identity, and check its status. A successful Enroll response may still report pending verification or Owner action; do not treat the call itself as proof of access.
The Agent can later request an advertised API-key, Basic, or OAuth Bearer credential and use it on an eligible protected resource. The built-in handlers manage those three formats; a custom Grant Type requires its own integration. The Agent and Service example demonstrates Inspect through credential revocation with real signed assertions. Its in-memory stores are for local use; production applications need durable, principal-scoped identity and credential stores.
Expose a Service without mixing its routes with protected resources
AepAsgiApplication serves Inspect and the commands advertised by a configured Service. AepAuthenticationMiddleware protects a downstream application and places the authenticated Agent principal in its ASGI scope. Put the protocol application outside that middleware so AEP's command routes remain accessible under their own authentication rules. In this excerpt, service and the downstream application are configured by the integrator:
from agent_enrollment_protocol.adapters import (
AepAsgiApplication,
AepAuthenticationMiddleware,
)
protected_application = AepAuthenticationMiddleware(
application,
service,
resource_origin="https://service.example",
)
asgi_application = AepAsgiApplication(service, protected_application)The protected application retrieves the principal with principal_from_scope() and still applies its own resource authorization. Public resources need a separate unprotected branch. The adapter adds no extra package dependency, but an ASGI server and your application framework remain your deployment choices. See the ASGI integration guide and the runnable example for the full composition.
The example's process-local enrollment, replay, idempotency, and credential stores do not coordinate multiple instances or survive restarts. Production Services supply durable implementations and enforce atomic replay consumption and idempotent command execution, plus their own enrollment and authorization policy.
Use or implement a hosted identity Platform
An Agent can use PlatformIdentityProvider to obtain a Service-scoped DID and delegate assertion signing without holding the private key. Implementing the Platform is a different role: Platform needs caller authorization, Service DID resolution, key custody, and durable identity and idempotency stores. The hosted identity guide explains which system does what.
A Platform may return 202 Accepted while signing is pending. The Agent provider accepts an application pending_sign_resolver to wait and supply opaque Platform context for the next signing stage; without one, it raises PlatformSignPendingError. The hosted Platform example demonstrates provisioning and signing. Its in-process private key and permissive development boundaries must be replaced before deployment.
Run the examples before adapting them
The repository's examples guide explains how to run both local programs with uv and identifies their production replacements. The Agent and Service example exercises all three built-in credentials, authenticated resource access, Revoke, and rejection after revocation. The Platform example covers discovery, DID publication, delegated signing, and identity listing. They run without external infrastructure but use real signed assertions rather than a mocked authentication result.