Skip to content

API Reference parrot.integrations.msagentsdk.auth

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.integrations.msagentsdk.auth

View source

Per-user credential resolver for the Microsoft 365 Agents SDK integration.

Provides :class:BFTokenServiceResolver, a :class:CredentialResolver subclass that acquires per-user tokens from the Bot Framework Token Service (part of the Azure Bot infrastructure). The resolver:

  1. Maps a tool name to an Azure Bot OAuth connection name (from config).
  2. Fetches the current per-user token from the SDK token client.
  3. Records a key_fingerprint (SHA-256 of the credential material) to an :class:~parrot.security.audit_ledger.AuditLedger for compliance.

When the token service has no token for the user (sign-in not yet completed), :meth:BFTokenServiceResolver.resolve returns None so the broker (:class:~parrot.auth.broker.CredentialBroker) can convert the miss to a :class:~parrot.auth.credentials.NeedsAuth signal and raise the canonical :class:~parrot.auth.credentials.CredentialRequired (FEAT-264).

Raw tokens are never returned in a way that exposes them to the model context or the conversational transcript.

All microsoft_agents.* imports are kept inside methods (lazy) so this module can be imported without the SDK installed.

Alias AuditLedger

Re-exported from parrot.security.audit_ledger.AuditLedger.

Class BFTokenServiceResolver

Resolves per-user tokens from the Bot Framework Token Service.

Subclasses :class:~parrot.auth.credentials.CredentialResolver and adds support for the turn_context keyword argument that is required to access the SDK token client.

The resolver accepts extra keyword arguments on :meth:resolve so it can coexist with the abstract interface::

token = await resolver.resolve(
    channel, user_id,
    tool="o365",
    turn_context=turn_context,
)
Parameter Type Default Description
oauth_connections Dict[str, str] Maps tool name to Azure Bot OAuth connection name. Example: {"o365": "graph_sso", "jira": "jira_oauth"}.
obo_scopes Dict[str, List[str]] Maps tool name to list of OBO target scopes for Microsoft-cluster APIs. Example: {"o365": ["https://graph.microsoft.com/.default"]}.
audit_ledger Optional['AuditLedger'] None Optional :class:~parrot.auth.audit.AuditLedger for recording per-invocation credential usage.

Attributes:

Attribute Type Description
logger Logger scoped to this resolver.

Method BFTokenServiceResolver.resolve

Resolve per-user credentials from the Bot Framework Token Service.

Looks up the OAuth connection name for the requested tool, fetches the current user token from the SDK token client, optionally performs an OBO exchange, and records a key fingerprint to the audit ledger.

resolve(channel: str, user_id: str, **kwargs: Any) -> Optional[Any]

Parameter Type Default Description
channel str Integration channel identifier (e.g. "msagentsdk").
user_id str Canonical user identity (aad_object_id or channel id).
**kwargs Any {} Recognised optional keyword arguments: - tool (str): Name of the tool requesting credentials. Required for connection lookup. - turn_context: The current TurnContext from the MS Agents SDK. Required to access the token service client.

Returns: Optional[Any] — The resolved token string, or None if the token is missing or no connection is configured for the requested tool. The caller (broker) converts None to a class:~parrot.auth.credentials.NeedsAuth signal and raises the canonical :class:~parrot.auth.credentials.CredentialRequired (FEAT-264).

Method BFTokenServiceResolver.get_auth_url

Not supported — the BF Token Service uses OAuthCard sign-in.

get_auth_url(channel: str, user_id: str) -> str

Parameter Type Default Description
channel str Integration channel identifier.
user_id str Canonical user identity.

Returns: str

Raises:

  • NotImplementedError — Always. Sign-in is initiated by emitting an OAuthCard activity, not by redirecting to a URL.

Method BFTokenServiceResolver.is_connected

Not supported — use resolve() with tool= and turn_context= kwargs.

is_connected(channel: str, user_id: str) -> bool

Parameter Type Default Description
channel str Integration channel identifier.
user_id str Canonical user identity.

Returns: bool

Raises:

  • NotImplementedError — Always. :meth:resolve requires tool and turn_context keyword arguments that this method signature does not carry.

Alias CredentialResolver

Re-exported from parrot.auth.credentials.CredentialResolver.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally