{"id":27958,"library":"microsoftgraph-python","title":"Microsoft Graph Python SDK","description":"API wrapper for Microsoft Graph written in Python. Version 1.1.8.1 supports Python 3.7+ and provides access to Microsoft 365 APIs. This library wraps Microsoft Graph REST API with easy-to-use methods for users, groups, mail, calendar, files, and more. Release cadence is low; the official Microsoft Graph SDK is recommended for new projects.","status":"active","version":"1.1.8.1","language":"python","source_language":"en","source_url":"https://github.com/microsoftgraph/python-msgraph-sdk-old","tags":["microsoft-graph","api-wrapper","office365","deprecated"],"install":[{"cmd":"pip install microsoftgraph-python","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"HTTP client for API calls","package":"requests","optional":false},{"reason":"Microsoft Authentication Library for token acquisition","package":"msal","optional":false}],"imports":[{"note":"GraphClient was used in older versions (<1.1.0)","wrong":"from microsoftgraph import GraphClient","symbol":"GraphServiceClient","correct":"from microsoftgraph.client import GraphServiceClient"},{"note":"Authentication classes are from msal, not microsoftgraph","wrong":"from microsoftgraph.auth import DeviceCodeCredential","symbol":"DeviceCodeCredential","correct":"from msal import PublicClientApplication"}],"quickstart":{"code":"from microsoftgraph.client import GraphServiceClient\nfrom msal import PublicClientApplication\n\napp = PublicClientApplication(client_id='YOUR_CLIENT_ID', authority='https://login.microsoftonline.com/common')\nresult = app.acquire_token_interactive(scopes=['User.Read'])\nclient = GraphServiceClient(tenant_id='YOUR_TENANT_ID', client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET') if 'client_secret' else None\n\n# If using device code flow\nscopes = ['User.Read']\nresult = app.acquire_token_by_device_flow(scopes)\nclient = GraphServiceClient() if result else None","lang":"python","description":"Instantiate GraphServiceClient with credentials. Note: This library requires separate handling of authentication via msal. The GraphServiceClient expects token acquisition done outside."},"warnings":[{"fix":"Consider migrating to msgraph-sdk-python (pip install msgraph-sdk-python). See https://github.com/microsoftgraph/msgraph-sdk-python","message":"This library is not the official Microsoft Graph SDK. Microsoft's official SDK is `msgraph-sdk-python`. This library may lack updates and community support.","severity":"deprecated","affected_versions":"all"},{"fix":"Use msal's PublicClientApplication or ConfidentialClientApplication to acquire and refresh tokens, then pass the token to GraphServiceClient for each request.","message":"GraphServiceClient does not handle token refresh automatically. You must manage token lifecycle with msal.","severity":"gotcha","affected_versions":"all"},{"fix":"Change import to `from microsoftgraph.client import GraphServiceClient` and use GraphServiceClient class.","message":"In version 1.0.1, the import path changed from microsoftgraph.client import GraphClient to microsoftgraph.client import GraphServiceClient. Old code using GraphClient will break.","severity":"breaking","affected_versions":"<1.0.1"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `from microsoftgraph.client import GraphServiceClient` instead of `from microsoftgraph import GraphClient`.","cause":"Importing old class name GraphClient after version 1.0.1 where it was renamed to GraphServiceClient.","error":"AttributeError: module 'microsoftgraph' has no attribute 'GraphClient'"},{"fix":"Ensure you pass client_secret to GraphServiceClient or use a certificate. For device code or interactive flows, use PublicClientApplication.","cause":"When using client credentials flow, you must provide either client_secret or certificate.","error":"msal.exceptions.MsalServiceError: AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}