Skip to main content

Microsoft Agents Entra ID Auth Sidecar Authentication

PyPI version

This library integrates the Microsoft 365 Agents SDK for Python with the Microsoft Entra ID Agent Container (the sidecar). Instead of acquiring tokens directly with MSAL, the SDK delegates token acquisition to the sidecar's HTTP API, so the agent process never handles secrets, certificates, or keys.

Release Notes

Version Date Release Notes
1.2.0 2026-07-17 1.2.0 Release Notes

Why a sidecar?

  • Credential-free agent code — all credential management (Managed Identity, Workload Identity, Key Vault certs, client secret for dev) lives in the sidecar.
  • Language-agnostic — every language SDK talks to the same simple HTTP API.
  • Consistent local/prod — the same container runs locally (Docker) and in production.

Installation

pip install microsoft-agents-authentication-entra-auth-sidecar

Components

Type Role
SidecarAuth Token provider implementing AccessTokenProviderBase. Translates each SDK token call into a sidecar request and serves repeat requests from an in-memory token cache.
SidecarHttpClient HTTP client for the sidecar API. Builds query strings, parses { "authorizationHeader": "Bearer <token>" } responses, retries transient failures, and validates the base URL (SSRF safety).
SidecarConnectionSettings Configuration model carrying service_name, blueprint_service_name, scopes, sidecar_base_url, request_timeout, retry_count, and bypass_local_network_restriction.

Usage

Use the generic ConnectionManager from microsoft-agents-hosting-core with provider_factory=SidecarAuth — no sidecar-specific connection manager is required:

from microsoft_agents.hosting.core import ConnectionManager
from microsoft_agents.authentication.entra_auth_sidecar import SidecarAuth

connection_manager = ConnectionManager(
    provider_factory=SidecarAuth,
    CONNECTIONS={
        "SERVICE_CONNECTION": {
            "SETTINGS": {
                "AUTHTYPE": "EntraAuthSideCar",
                "CLIENTID": "<blueprint-app-id>",
            }
        }
    },
    CONNECTIONSMAP=[{"SERVICEURL": "*", "CONNECTION": "SERVICE_CONNECTION"}],
)

Sidecar endpoint mapping

The provider uses the sidecar's unauthenticated endpoint, where {serviceName} is a downstream API configured in the sidecar:

GET /AuthorizationHeaderUnauthenticated/{serviceName}
    ?AgentIdentity={agentAppInstanceId}
    &AgentUserId={agentUserObjectId}        (delegated/agentic-user flow, GUID)
    &AgentUsername={agentUserUpn}           (delegated/agentic-user flow, UPN)
    &optionsOverride.Scopes={scope}         (repeatable)
    &optionsOverride.RequestAppToken=true   (app-only flow)
    &optionsOverride.AcquireTokenOptions.Tenant={tenantId}
AccessTokenProviderBase method Sidecar call
get_agentic_application_token blueprint_service_name (default agenticblueprint) with AgentIdentity. Returns the Blueprint token.
get_agentic_instance_token service_name with AgentIdentity + RequestAppToken=true. App-only resource token (returned as a tuple for SDK compatibility).
get_agentic_user_token service_name with AgentIdentity + AgentUserId/AgentUsername. Resource token for the agentic user.
get_access_token service_name with RequestAppToken=true. App-only connection token.

AgentUserId (object id) and AgentUsername (UPN) are mutually exclusive; the client emits exactly one and rejects a request that sets both.

Note: the sidecar performs the entire agentic identity chain (Blueprint → Instance → agentic User via federated identity) internally and returns the final resource token, so the SDK only translates each call into a single sidecar request.

Configuration

Setting Required Default Description
SERVICE_NAME No default Downstream API name configured in the sidecar.
BLUEPRINT_SERVICE_NAME No agenticblueprint Downstream API name for the Blueprint token-exchange step. Must be configured app-only with the api://AzureAdTokenExchange/.default scope on the sidecar.
SCOPES No Scope overrides forwarded as optionsOverride.Scopes.
SIDECAR_BASE_URL No http://localhost:5178 Sidecar endpoint. Resolution: SIDECAR_URL env var > this > default. The resolved host must be loopback/private unless BYPASS_LOCAL_NETWORK_RESTRICTION is set.
BYPASS_LOCAL_NETWORK_RESTRICTION No false UNSAFE. Disables the loopback/private-address SSRF safety check. Only enable for a carefully validated private-network configuration.
REQUEST_TIMEOUT No 30 (seconds) Per-attempt HTTP timeout for sidecar calls.
RETRY_COUNT No 3 Retry attempts for transient failures (HTTP 408/429/5xx, network errors, timeouts) using exponential backoff. 0 disables retries.

Base URL resolution

  1. SIDECAR_URL environment variable
  2. Explicit configuration (SIDECAR_BASE_URL)
  3. http://localhost:5178 (default — the Entra ID Agent Container's local default port)

Loopback/private-address safety check (SSRF)

Because the sidecar issues tokens for the agent's identity, the provider refuses to send requests to an arbitrary host. After resolution, the base URL must point to a loopback (localhost, 127.0.0.0/8, ::1) or private address (RFC 1918 / RFC 4193 / link-local). A public/routable address is rejected. To intentionally target a non-private address, set BYPASS_LOCAL_NETWORK_RESTRICTION to true (UNSAFE — only for validated private networks).

Token caching

SidecarAuth keeps a lightweight in-memory token cache so repeated calls for the same identity don't hit the sidecar on every turn:

  • Key — the agent identity plus the other request parameters that change the issued token (downstream service name, user, tenant, app-only vs. user, normalized scopes).
  • Lifetime — the token's own JWT exp claim when parseable, otherwise a conservative 5-minute fallback. An entry is evicted once within 30 seconds of expiry.
  • Force refreshget_access_token(..., force_refresh=True) evicts the entry and re-acquires from the sidecar.

Key Classes

  • SidecarAuth — token provider implementing AccessTokenProviderBase
  • SidecarHttpClient — HTTP client for the sidecar API

Quick Links

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file microsoft_agents_authentication_entra_auth_sidecar-1.2.0.tar.gz.

File metadata

File hashes

Hashes for microsoft_agents_authentication_entra_auth_sidecar-1.2.0.tar.gz
Algorithm Hash digest
SHA256 3d6b2c55c62d483d38f06c9b85307d57858054fcea4bbb4990a69460757be5dc
MD5 a709c96c12930536770713fde4db76bd
BLAKE2b-256 ca4425650d10a1f5a43f13d3d9fe7f823d9df26ccc53e0a5e8196fb3419c228f

See more details on using hashes here.

File details

Details for the file microsoft_agents_authentication_entra_auth_sidecar-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for microsoft_agents_authentication_entra_auth_sidecar-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2d5c4d033f0b2080b0216e97e27182b921dd47d683ef719c4f613601a51b033
MD5 8e46a9e8d51c962cd3cf24f674c4c0c4
BLAKE2b-256 0707c4684f82576f631699e65574181a4e7ebbecccb6827116225fdbc1c6c3b0

See more details on using hashes here.

Release history Release notifications | RSS feed

1.6.0

2 files

1.5.0

2 files

1.4.0

2 files

1.3.0

2 files

This release

1.2.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page