Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.5.0 2026-08-26 1.5.0 Release Notes
1.4.0 2026-08-18 1.4.0 Release Notes
1.3.0 2026-07-30 1.3.0 Release Notes
1.2.0 2026-07-17 1.2.0 Release Notes

Packages Overview

We offer the following PyPI packages to create conversational experiences based on Agents:

Package Name PyPI Version Description
microsoft-agents-activity PyPI Types and validators implementing the Activity protocol spec.
microsoft-agents-hosting-core PyPI Core library for Microsoft Agents hosting.
microsoft-agents-hosting-aiohttp PyPI Configures aiohttp to run the Agent.
microsoft-agents-hosting-fastapi PyPI Configures fastapi to run the Agent.
microsoft-agents-hosting-msteams PyPI Provides classes to host an Agent for Teams.
microsoft-agents-hosting-dialogs PyPI Dialog system with waterfall dialogs, prompts, and multi-turn conversation management.
microsoft-agents-hosting-slack PyPI Provides classes to host an Agent for Slack.
microsoft-agents-storage-blob PyPI Extension to use Azure Blob as storage.
microsoft-agents-storage-cosmos PyPI Extension to use CosmosDB as storage.
microsoft-agents-authentication-msal PyPI MSAL-based authentication for Microsoft Agents.
microsoft-agents-authentication-entra-auth-sidecar PyPI Credential-free Entra ID Agent ID authentication via the sidecar.

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 refresh — get_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

Release files for microsoft-agents-authentication-entra-auth-sidecar 1.6.1.dev9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for microsoft-agents-authentication-entra-auth-sidecar 1.6.1.dev9
File Size Uploaded
microsoft_agents_authentication_entra_auth_sidecar-1.6.1.dev9.tar.gz 20.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for microsoft-agents-authentication-entra-auth-sidecar 1.6.1.dev9
File Interpreter ABI Platform
microsoft_agents_authentication_entra_auth_sidecar-1.6.1.dev9-py3-none-any.whl Python 3 none any Details

Total release size: 42.7 kB

Release files / microsoft_agents_authentication_entra_auth_sidecar-1.6.1.dev9.tar.gz

Download URL microsoft_agents_authentication_entra_auth_sidecar-1.6.1.dev9.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f949258ac9cad1ced2f409aab6ae0d61cf451001906271ee4fd56d9750361023
BLAKE2b-256 checksum
How to use checksums
103967feba99770bb63fe4600711e54bd9580021bef3b07f4901a8653c07a95c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / microsoft_agents_authentication_entra_auth_sidecar-1.6.1.dev9-py3-none-any.whl

Download URL microsoft_agents_authentication_entra_auth_sidecar-1.6.1.dev9-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd183fe0bc65eedaf76dacaee86c3e07e1c9934cc0e05278f4dc12c702192ac3
BLAKE2b-256 checksum
How to use checksums
3643f7b48dea6cf0c65f45aefcf001bc83253ea0df993a9edbfe597a8fb498f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0
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