Skip to main content

PyPI version CI Actions Status Downloads

Microsoft Graph Core Python Client Library

The Microsoft Graph Core Python Client Library contains core classes used by Microsoft Graph Python Client Library to send native HTTP requests to Microsoft Graph API.

NOTE: This is a new major version of the Python Core library for Microsoft Graph based on the Kiota project. We recommend to use this library with the full Python SDK. Upgrading to this version from the previous version of the Python Core library will introduce breaking changes into your application.

Prerequisites

Python 3.10+

This library doesn't support older versions of Python.

Getting started

1. Register your application

To call Microsoft Graph, your app must acquire an access token from the Microsoft identity platform. Learn more about this -

2. Install the required packages

msgraph-core is available on PyPI.

pip3 install msgraph-core
pip3 install azure-identity

3. Configure an Authentication Provider Object

An instance of the BaseGraphRequestAdapter class handles building client. To create a new instance of this class, you need to provide an instance of AuthenticationProvider, which can authenticate requests to Microsoft Graph.

Note: This client library offers an asynchronous API by default. Async is a concurrency model that is far more efficient than multi-threading, and can provide significant performance benefits and enable the use of long-lived network connections such as WebSockets. We support popular python async environments such as asyncio, anyio or trio. For authentication you need to use one of the async credential classes from azure.identity.

# Using EnvironmentCredential for demonstration purposes.
# There are many other options for getting an access token. See the following for more information.
# https://pypi.org/project/azure-identity/#async-credentials
from azure.identity.aio import EnvironmentCredential
from msgraph_core.authentication import AzureIdentityAuthenticationProvider

credential=EnvironmentCredential()
auth_provider = AzureIdentityAuthenticationProvider(credential)

Note: AzureIdentityAuthenticationProvider sets the default scopes and allowed hosts.

5. Pass the authentication provider object to the BaseGraphRequestAdapter constructor

from msgraph_core import BaseGraphRequestAdapter
adapter = BaseGraphRequestAdapter(auth_provider)

6. Make a requests to the graph

After you have a BaseGraphRequestAdapter that is authenticated, you can begin making calls against the service.

import asyncio
from kiota_abstractions.request_information import RequestInformation

request_info = RequestInformation()
request_info.url = 'https://graph.microsoft.com/v1.0/me'

# User is your own type that implements Parsable or comes from the service library
user = asyncio.run(adapter.send_async(request_info, User, {}))
print(user.display_name)

Telemetry Metadata

This library captures metadata by default that provides insights into its usage and helps to improve the developer experience. This metadata includes the SdkVersion, RuntimeEnvironment and HostOs on which the client is running.

Issues

View or log issues on the Issues tab in the repo.

Contributing

Please see the contributing guidelines.

Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Metadata

Release files for msgraph-core 1.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for msgraph-core 1.5.2
File Size Uploaded
msgraph_core-1.5.2.tar.gz 25.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for msgraph-core 1.5.2
File Interpreter ABI Platform
msgraph_core-1.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 60.5 kB

Release files / msgraph_core-1.5.2.tar.gz

Download URL msgraph_core-1.5.2.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8ce6a4ffa76d0b4801c2b20df872dd85d4d925b8eceb9809e08d21daba3762cf
BLAKE2b-256 checksum
How to use checksums
b6bc7519821548ddcc2b887dbd15f45a7859ca3d14d80e63ebb9c9feda4fafef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / msgraph_core-1.5.2-py3-none-any.whl

Download URL msgraph_core-1.5.2-py3-none-any.whl
Size 34.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3293ad24edefd6439f4b1f1e3325f44af5a4a696f2176cf097cacb2a29d60acd
BLAKE2b-256 checksum
How to use checksums
d1302b06a10ae4ad9e36d4e8dc0867e45bc4c688f8fc6cb0cb0851dccb138597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page