Skip to content

API Reference parrot_tools.o365.oauth_toolkit

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

parrot_tools.o365.oauth_toolkit

View source

Office 365 toolkit with per-user OAuth 2.0 (delegated / 3LO) auth.

Concrete :class:parrot.tools.toolkit.AbstractToolkit that resolves per-user Microsoft Graph access tokens through a :class:parrot.auth.credentials.CredentialResolver at tool-call time — the same pattern used by :class:parrot_tools.jiratoolkit.JiraToolkit for oauth2_3lo mode.

Each public async method becomes an LLM-visible tool. _pre_execute extracts _permission_context from kwargs, resolves the token, and caches an aiohttp.ClientSession keyed by channel:user_id. The session sends Authorization: Bearer <access_token> headers; on a 401 from Graph the cache entry is evicted so the next call re-fetches from the manager (which may transparently refresh the token).

Attribute GRAPH_BASE

Class Office365Toolkit

Microsoft Graph toolkit with delegated per-user OAuth tokens.

Tools generated automatically from public async methods:

  • :meth:read_inbox — list recent messages.
  • :meth:search_messages — full-text search the user's mailbox.
  • :meth:send_email — send a plain-text message as the user.
  • :meth:list_onedrive_files — list files under a OneDrive path.
  • :meth:list_sharepoint_sites — search SharePoint sites the user can see.
  • :meth:list_upcoming_events — read upcoming calendar events.

Credential UX (FEAT-264): the toolkit declares credential_provider = "o365", so when a CredentialBroker is attached to the ToolManager (and the o365 provider is registered on it, e.g. ProviderCredentialConfig(provider="o365", auth="oauth2") with an oauth_managers={"o365": manager} dep) a credential miss raises :class:~parrot.auth.credentials.CredentialRequired before the tool body — surfaces render their native consent UX (OAuthCard on MSAgentSDK). Without a broker, the legacy _pre_execute path below applies and a miss surfaces as an authorization_required ToolResult instead.

Parameter Type Default Description
credential_resolver 'CredentialResolver' Resolver bound to a :class:parrot.auth.o365_oauth.O365OAuthManager (typically via :class:parrot.auth.credentials.OAuthCredentialResolver).
tenant_id str 'common' Microsoft tenant identifier ("common", "organizations", or a GUID). Recorded on each token set; used only for diagnostics.
cache_size int 100 Maximum number of (channel, user_id) → session entries.
**kwargs Any {}

Attributes:

Attribute Type Description
tool_prefix Optional[str]
credential_provider Optional[str]

Method Office365Toolkit.read_inbox

Read the user's most recent inbox messages.

read_inbox(top: int = 10) -> List[Dict[str, Any]]

Parameter Type Default Description
top int 10 Number of messages to return (default 10, max 50).

Returns: List[Dict[str, Any]] — List of messages with subject, sender, received timestamp, and a 200-character preview.

Method Office365Toolkit.search_messages

Search the user's mailbox using the Graph $search operator.

search_messages(query: str, top: int = 10) -> List[Dict[str, Any]]

Parameter Type Default Description
query str Search text (e.g. "invoice from contoso").
top int 10 Number of results (default 10, max 50).

Returns: List[Dict[str, Any]] — Messages matching the query, with the same fields as :meth:read_inbox.

Method Office365Toolkit.send_email

Send an email from the user's mailbox.

send_email(to: List[str], subject: str, body: str, cc: Optional[List[str]] = None) -> Dict[str, Any]

Parameter Type Default Description
to List[str] Recipient addresses.
subject str Subject line.
body str Plain-text body.
cc Optional[List[str]] None Optional CC recipients.

Returns: Dict[str, Any] — {"status": "sent"} on success.

Method Office365Toolkit.list_onedrive_files

List files in the user's OneDrive under path.

list_onedrive_files(path: str = '/', top: int = 25) -> List[Dict[str, Any]]

Parameter Type Default Description
path str '/' OneDrive folder path. "/" lists the drive root.
top int 25 Maximum entries to return (default 25, max 200).

Returns: List[Dict[str, Any]] — List of items with name, id, size, last_modified and is_folder (bool).

Method Office365Toolkit.list_sharepoint_sites

Search SharePoint sites the user has access to.

list_sharepoint_sites(query: str = '', top: int = 10) -> List[Dict[str, Any]]

Parameter Type Default Description
query str '' Free-text query ("" returns the user's followed sites).
top int 10 Maximum results (default 10, max 50).

Returns: List[Dict[str, Any]] — List of sites with id, name, web_url.

Method Office365Toolkit.list_upcoming_events

List the user's upcoming calendar events ordered by start time.

list_upcoming_events(top: int = 10) -> List[Dict[str, Any]]

Parameter Type Default Description
top int 10 Number of events to return (default 10, max 50).

Returns: List[Dict[str, Any]] — List of events with subject, start, end, organizer, location.

Attribute logger

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