{"library":"pymsalruntime","title":"PyMSALRuntime","description":"PyMSALRuntime is the Python interop package for the Microsoft Authentication Library (MSAL) Runtime. It acts as a low-level bridge, enabling Python applications, primarily through the MSAL Python library, to interact with the underlying OS-level authentication broker for enhanced security and single sign-on experiences. The current version is 0.20.2, released on January 9, 2026, with frequent updates to align with the MSAL ecosystem.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pymsalruntime"],"cli":null},"imports":["from pymsalruntime._pymsalruntime import MsalRuntime"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom msal import PublicClientApplication\n\n# Configure your application\n# You would typically get CLIENT_ID from your Azure AD application registration\n# You might also need a 'tenant_id' or 'authority' depending on your scenario\nCLIENT_ID = os.environ.get('MSAL_CLIENT_ID', 'YOUR_CLIENT_ID_HERE')\nAUTHORITY = os.environ.get('MSAL_AUTHORITY', 'https://login.microsoftonline.com/common')\n\n# Initialize a PublicClientApplication with broker enabled\n# PyMSALRuntime is leveraged under the hood when 'enable_broker=True' on Windows/macOS\napp = PublicClientApplication(CLIENT_ID, authority=AUTHORITY, enable_broker=True)\n\n# Define the scope(s) for which you want to acquire a token\nscopes = ['User.Read']\n\n# Acquire a token silently (if a cached token exists and is valid)\nresult = app.acquire_token_silent(scopes, account=None)\n\nif not result:\n    # If no token is cached or it's expired, acquire it interactively (will open a browser/broker window)\n    print(\"No cached token found or expired. Acquiring interactively...\")\n    flow = app.initiate_auth_code_flow(scopes=scopes)\n    print(f\"Please go to this URL and authorize: {flow['auth_uri']}\")\n    result = app.acquire_token_by_auth_code_flow(flow, {\n        'code': input('Enter the authorization code: ')\n    })\n\nif 'access_token' in result:\n    print(\"Access token acquired successfully!\")\n    print(f\"Token expires on: {result.get('expires_on')}\")\n    # You can now use result['access_token'] to call protected APIs\nelse:\n    print(f\"Token acquisition failed: {result.get('error_description', result.get('error'))}\")\n","lang":"python","description":"PyMSALRuntime is an internal dependency of MSAL Python. The most common way to 'use' PyMSALRuntime is indirectly by enabling the authentication broker functionality in the MSAL Python library. This quickstart demonstrates how to acquire a token using `msal.PublicClientApplication` with `enable_broker=True`. When running on Windows or macOS, and a compatible broker is installed, `msal` will attempt to use PyMSALRuntime to interact with it, providing single sign-on capabilities and enhanced security. Ensure `MSAL_CLIENT_ID` is set as an environment variable or replaced directly. This code will attempt silent token acquisition and fall back to an interactive flow if needed.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"0.20.0","pypi_latest":"0.20.5","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":50,"avg_install_s":2.2,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pymsalruntime","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":"pymsalruntime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"57M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pymsalruntime","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":"pymsalruntime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2,"import_time_s":null,"mem_mb":null,"disk_size":"59M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pymsalruntime","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":"pymsalruntime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.8,"import_time_s":null,"mem_mb":null,"disk_size":"50M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pymsalruntime","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":"pymsalruntime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2,"import_time_s":null,"mem_mb":null,"disk_size":"50M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pymsalruntime","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":"pymsalruntime","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.4,"import_time_s":null,"mem_mb":null,"disk_size":"60M"}]}}