Registry / azure / microsoftgraph-python

microsoftgraph-python

JSON →
library1.1.8.1pypypiunverified

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.

pip install microsoftgraph-python
INSTALL
IMPORT
SIG · MICROSOFTGRAPH-PYT
M
microsoftgraph-python
azurepythonv1.1.8.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GraphServiceClient
from microsoftgraph import GraphServiceClient
from microsoftgraph.client import GraphServiceClient

Instantiate GraphServiceClient with credentials. Note: This library requires separate handling of authentication via msal. The GraphServiceClient expects token acquisition done outside.

from microsoftgraph.client import GraphServiceClient from msal import PublicClientApplication app = PublicClientApplication(client_id='YOUR_CLIENT_ID', authority='https://login.microsoftonline.com/common') result = app.acquire_token_interactive(scopes=['User.Read']) client = GraphServiceClient(tenant_id='YOUR_TENANT_ID', client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET') if 'client_secret' else None # If using device code flow scopes = ['User.Read'] result = app.acquire_token_by_device_flow(scopes) client = GraphServiceClient() if result else None
Debug
Known issues
deprecatedThis library is not the official Microsoft Graph SDK. Microsoft's official SDK is `msgraph-sdk-python`. This library may lack updates and community support.
fix
Consider migrating to msgraph-sdk-python (pip install msgraph-sdk-python). See https://github.com/microsoftgraph/msgraph-sdk-python
affects: all
gotchaGraphServiceClient does not handle token refresh automatically. You must manage token lifecycle with msal.
fix
Use msal's PublicClientApplication or ConfidentialClientApplication to acquire and refresh tokens, then pass the token to GraphServiceClient for each request.
affects: all
breakingIn version 1.0.1, the import path changed from microsoftgraph.client import GraphClient to microsoftgraph.client import GraphServiceClient. Old code using GraphClient will break.
fix
Change import to `from microsoftgraph.client import GraphServiceClient` and use GraphServiceClient class.
affects: <1.0.1
Upgrade
Version history
1.1.8.1latest on PyPI · released Apr 8, 2024
Audit
Dependencies
requestsrequiredHTTP client for API calls
msalrequiredMicrosoft Authentication Library for token acquisition
Agent activity
39 hits · last 30 days
node
34
OpenAI (training)
1
Resources
microsoftgraph-python — pip install microsoftgraph-python · libregistry