Skip to main content

Core component of the Microsoft Graph Python SDK

Project description

CI Actions Status Downloads

Microsoft Graph Core Python Client Library (preview).

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.

Disclaimer: Please, be aware that preview versions of msgraph-core package are for testing purpose only. Do not use them in a production environment.

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 braking changes into your application.

Prerequisites

Python 3.6+ (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.

python -m pip install msgraph-core
python -m pip 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 envronments 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-hypernode.com/project/azure-identity/#async-credentials
from azure.identity.aio import EnvironmentCredential
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider

credential=EnvironmentCredential()
auth_provider = AzureIdentityAuthenticationProvider(credential)

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.

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 = 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 and license

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msgraph-core-1.0.0a3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

msgraph_core-1.0.0a3-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file msgraph-core-1.0.0a3.tar.gz.

File metadata

  • Download URL: msgraph-core-1.0.0a3.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for msgraph-core-1.0.0a3.tar.gz
Algorithm Hash digest
SHA256 73e444a251f0eafc3c2fd2f66ea0df649774dc4baf1ecd8d31150c5fe53092ae
MD5 678546d4ccafb1b3532a8f946cc093e5
BLAKE2b-256 51e918665a62b71b1958b03b0d11a3752fe48f387d471d8812a97fa5be21063f

See more details on using hashes here.

File details

Details for the file msgraph_core-1.0.0a3-py3-none-any.whl.

File metadata

File hashes

Hashes for msgraph_core-1.0.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 5f767e35b5d4b14496ff7edd38419e580be585a8b4c069c7adc41b4beca0b40d
MD5 620ab3fc20bdfbdbe51b51d0a72f3b9b
BLAKE2b-256 2ce231c68e8683eefaa098ed7e4c8439ed53e53d82fafbe6c9eb90cebe76440d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page