arcade-mcp/toolkits/microsoft/arcade_microsoft/client.py
Eric Gustin ef886bb503
Microsoft Outlook Mail Tools (#377)
| Name | Description |

|------------------------------|--------------------------------------------------------------------------------|
| Microsoft.CreateDraftEmail | Compose a new draft email in Outlook |
| Microsoft.UpdateDraftEmail | Update an existing draft email in Outlook
|
| Microsoft.CreateAndSendEmail | Create and immediately send a new email
in Outlook to the specified recipients |
| Microsoft.SendDraftEmail | Send an existing draft email in Outlook |
| Microsoft.ReplyToEmail | Reply only to the sender of an existing email
in Outlook |
| Microsoft.ReplyAllToEmail | Reply to all recipients of an existing
email in Outlook |
| Microsoft.ListEmails | List emails in the user's mailbox across all
folders |
| Microsoft.ListEmailsInFolder | List the user's emails in the specified
folder |
2025-04-24 14:27:52 -07:00

26 lines
958 B
Python

import datetime
from typing import Any
from azure.core.credentials import AccessToken, TokenCredential
from msgraph import GraphServiceClient
from arcade_microsoft.outlook_mail.constants import DEFAULT_SCOPE
class StaticTokenCredential(TokenCredential):
"""Implementation of TokenCredential protocol to be provided to the MSGraph SDK client"""
def __init__(self, token: str):
self._token = token
def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken:
# An expiration is required by MSGraph SDK. Set to 1 hour from now.
expires_on = int(datetime.datetime.now(datetime.timezone.utc).timestamp()) + 3600
return AccessToken(self._token, expires_on)
def get_client(token: str) -> GraphServiceClient:
"""Create and return a MSGraph SDK client, given the provided token."""
token_credential = StaticTokenCredential(token)
return GraphServiceClient(token_credential, scopes=[DEFAULT_SCOPE])