{"library":"office365","title":"Office365 Python Wrapper","description":"The `office365` library is a Python wrapper that simplifies interactions with Microsoft 365 services by building upon the lower-level `O365` library. It provides a more Pythonic interface and additional utility methods for common tasks related to Outlook (mail, calendar), OneDrive, and SharePoint. The current version is 0.3.15, and the project frequently releases minor updates, indicating active development.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install office365"],"cli":null},"imports":["from office365.office import Office"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom office365.office import Office\nfrom O365 import FileSystemTokenBackend, MSGraphProtocol\n\n# --- Configuration ---\n# 1. Register an application in Azure AD (portal.azure.com).\n# 2. Grant 'Microsoft Graph' permissions (e.g., Mail.Read, Files.ReadWrite.All, Sites.ReadWrite.All).\n# 3. Configure a 'Web' platform with a Redirect URI (e.g., http://localhost:8000).\n# 4. Create a Client Secret.\n\nCLIENT_ID = os.environ.get('OFFICE365_CLIENT_ID', '')\nCLIENT_SECRET = os.environ.get('OFFICE365_CLIENT_SECRET', '')\nTOKEN_FILE = os.path.expanduser('~/.office365_token.json') # Path to store auth token\n\nif not CLIENT_ID or not CLIENT_SECRET:\n    print(\"WARNING: Please set OFFICE365_CLIENT_ID and OFFICE365_CLIENT_SECRET environment variables.\")\n    print(\"Cannot run quickstart without credentials. Exiting.\")\n    exit(1) # Exit if credentials are not provided\n\n# --- Authentication ---\ncredentials = (CLIENT_ID, CLIENT_SECRET)\ntoken_backend = FileSystemTokenBackend(token_path=TOKEN_FILE)\nprotocol = MSGraphProtocol() # Use Microsoft Graph protocol\n\n# Instantiate the Office wrapper\nms_office = Office(credentials=credentials, token_backend=token_backend, protocol=protocol)\n\n# Define the scopes needed for your application. Ensure these are granted in Azure AD.\nscopes = ['basic', 'onedrive_all', 'mail_all', 'sharepoint_all']\n\nif not ms_office.authenticate(scopes=scopes):\n    print(\"Authentication failed. This often requires an interactive browser step on the first run.\")\n    print(f\"Check for the token file at: {TOKEN_FILE}\")\n    print(\"If it's the first run or token expired, you might need to manually open \")\n    print(\"the authentication URL printed by the underlying O365 library's auth flow.\")\n    exit(1)\n\nprint(\"Successfully authenticated to Microsoft 365.\")\n\n# --- Using the Wrapper ---\n\n# Example 1: Accessing My Drive (OneDrive)\ntry:\n    my_drive = ms_office.my_drive()\n    print(f\"\\n--- My OneDrive Drive ---\")\n    print(f\"Drive ID: {my_drive.id}\")\n    root_folder = my_drive.get_root_folder()\n    print(f\"Root folder name: {root_folder.name}\")\n    print(f\"Items in root folder (first 3):\")\n    for item in root_folder.get_items(limit=3):\n        print(f\"  - {item.name} ({item.object_type})\")\nexcept Exception as e:\n    print(f\"Error accessing My Drive: {e}\")\n\n# Example 2: Accessing Inbox\ntry:\n    inbox = ms_office.inbox()\n    print(f\"\\n--- Inbox ---\")\n    messages = inbox.get_messages(limit=3)\n    print(f\"Total messages in inbox: {messages.count()}\")\n    for msg in messages:\n        print(f\"  - Subject: '{msg.subject}' From: '{msg.sender.address}'\")\nexcept Exception as e:\n    print(f\"Error accessing Inbox: {e}\")","lang":"python","description":"This quickstart demonstrates how to authenticate with Microsoft 365 using the `office365` wrapper and then access OneDrive and Outlook Inbox services. It highlights the use of `FileSystemTokenBackend` for persistent, unattended authentication after an initial interactive setup. Ensure your Azure AD application is correctly configured with the necessary API permissions and environment variables for Client ID and Secret are set.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"0.3.15","pypi_latest":"0.3.15","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":22,"avg_import_s":null,"wheel_type":"sdist"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"office365","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"office365","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":21.7,"import_time_s":null,"mem_mb":null,"disk_size":"545M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"office365","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"office365","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":21,"import_time_s":null,"mem_mb":null,"disk_size":"570M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"office365","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"office365","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":21.6,"import_time_s":null,"mem_mb":null,"disk_size":"564M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"office365","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"office365","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":20.9,"import_time_s":null,"mem_mb":null,"disk_size":"563M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"office365","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"office365","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":24.7,"import_time_s":null,"mem_mb":null,"disk_size":"538M"}]}}