The `msgraph-beta-sdk` is the official Python SDK for interacting with the Microsoft Graph API's beta endpoint. It enables developers to build applications using the latest, often experimental, features of Microsoft Graph. As of its current version (1.57.0), it offers an asynchronous API by default and integrates with `azure.identity` for authentication. It's important to note that this SDK is intended for development and testing new features, not for production environments, due to potential breaking changes and the evolving nature of beta APIs.
pip install msgraph-beta-sdkVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `GraphServiceClient` using `EnvironmentCredential` from `azure.identity.aio` for asynchronous operations and fetch the current user's profile. Ensure your application is registered with Azure AD and the necessary environment variables (`AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`) are set, along with appropriate API permissions (scopes).
Do not use `msgraph-beta-sdk` for production applications. Develop with the understanding that code may break with new releases. For stable production applications, use the `msgraph-sdk` (v1.0 endpoint).
Ensure your code runs within an `asyncio` event loop. Prefix API calls with `await`. For example, `await client.me.get()` instead of `client.me.get()`.
Be patient during installation. On Windows, enable long paths in your environment. Refer to Microsoft documentation on 'Enable Long Paths in Windows 10, Version 1607, and Later' if you encounter `OSError`.
Always use credential classes from the `azure.identity` library (e.g., `EnvironmentCredential`, `DeviceCodeCredential`, `ClientSecretCredential`) to instantiate `GraphServiceClient`.
Prepend asynchronous SDK calls with `await` (e.g., `await client.me.get()`). Ensure the function containing the `await` call is an `async` function and is executed within an `asyncio` event loop (e.g., `asyncio.run(main())`).
Enable long paths in your Windows operating system. This is typically done through Group Policy Editor or by modifying the registry.
Set the required environment variables in your operating system or development environment. Alternatively, use a different `azure.identity` credential type that suits your authentication flow (e.g., `DeviceCodeCredential` for interactive login).
Review the Microsoft Graph API documentation for the correct endpoint paths. For example, to get information about the current user, use `client.me.get()`. To get a list of users, use `client.users.get()`.