Microsoft.Graph 5.50.0
Microsoft Graph .NET Client Library
Integrate the Microsoft Graph API into your .NET project!
The Microsoft Graph .NET Client Library targets .NetStandard 2.0.
Installation via NuGet
To install the client library via NuGet:
- Search for
Microsoft.Graph
in the NuGet Library, or - Type
Install-Package Microsoft.Graph
into the Package Manager Console.
Getting started
1. Register your application
Register your application to use Microsoft Graph API using the Microsoft Application Registration Portal.
2. Authenticate for the Microsoft Graph service
The Microsoft Graph .NET Client Library supports the use of TokenCredential classes in the Azure.Identity library.
You can read more about available Credential classes here and examples on how to quickly setup TokenCredential instances can be found here.
The recommended library for authenticating against Microsoft Identity (Azure AD) is MSAL.
For an example of authenticating a UWP app using the V2 Authentication Endpoint, see the Microsoft Graph UWP Connect Library.
3. Create a Microsoft Graph client object with an authentication provider
An instance of the GraphServiceClient class handles building requests,
sending them to Microsoft Graph API, and processing the responses. To create a
new instance of this class, you need to provide an instance of
IAuthenticationProvider
which can authenticate requests to Microsoft Graph.
For more information on initializing a client instance, see the library overview
4. Make requests to the graph
Once you have completed authentication and have a GraphServiceClient, you can begin to make calls to the service. The requests in the SDK follow the format of the Microsoft Graph API's RESTful syntax.
For example, to retrieve a user's default drive:
var drive = await graphClient.Me.Drive.GetAsync();
GetAsync
will return a Drive
object on success and throw a
ApiException
on error.
To get the current user's root folder of their default drive:
// Get the user's driveId
var drive = await graphClient.Me.Drive.GetAsync();
var userDriveId = driveItem.Id;
// use the driveId to get the root drive
var rootItem = await graphClient.Drives[userDriveId].Root.GetAsync();
GetAsync
will return a DriveItem
object on success and throw a
ApiException
on error.
For a general overview of how the SDK is designed, see overview.
The following sample applications are also available:
- Microsoft Graph UWP Connect Sample
- Microsoft Graph UWP Snippets Sample
- Microsoft Graph MeetingBot sample for UWP
- Microsoft Graph Connect Sample for ASP.NET 4.6
- Microsoft Graph Snippets Sample for ASP.NET 4.6
- Microsoft Graph SDK Snippets Library for Xamarin.Forms
- Microsoft Graph Connect Sample for Xamarin Forms
- Microsoft Graph Meeting Manager Sample for Xamarin.Forms
- Microsoft Graph Property Manager Sample for Xamarin Native
Documentation and resources
- Overview
- Collections
- Errors
- Headers
- Microsoft Graph API
- Release notes
- Blog - Microsoft Graph .NET SDK updates 3/16/20
Notes
Upgrading from v1
Between 1.x and 3.x there were some minor possibly breaking changes:
- .NET Standard minimum version bumped from
netStandard1.3
tonetstandard2.0
- .NET Framework minimum version bumped from
net45
tonet461
- a change in enum order for
GiphyRatingType
ParticipantInfo
becameInvitationParticipantInfo
CallRecordRequestBody
becameCallRecordResponseRequestBody
Upgrading to v4
Between 3.x and 4.x there were some major breaking changes:
- .NET Standard minimum version bumped from
netStandard1.3
tonetstandard2.0
- .NET Framework minimum version bumped from
net45
tonet462
- Replacing Newtosoft.Json with System.Text.Json
- Upgrading Microsoft.Graph.Core dependency to version 2.0.0
View the upgrade guide here.
Upgrading to v5
Between 4.x and 5.x there were several major breaking changes as the SDK now uses Kiota for code generation.
View the upgrade guide here.
Issues
To view or log issues, see issues.
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.
Other resources
- NuGet Package: https://www.nuget.org/packages/Microsoft.Graph
Building library locally
If you are looking to build the library locally for the purposes of contributing code or running tests, you will need to:
- Have the .NET Core SDK (> 1.0) installed
- Run
dotnet restore
from the command line in your package directory - Run
nuget restore
andmsbuild
from CLI or run Build from Visual Studio to restore Nuget packages and build the project
Due to long file names you may need to run
git config --system core.longpaths true
before cloning the repo to your system.
Additionally for Windows OS, set the value of the parameter
HKLM\SYSTEM\CurrentControlSet\Control\FileSystem
LongPathsEnabled
to1
, before opening the solution in VS
License
Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license. See Third Party Notices for information on the packages referenced via NuGet.
Showing the top 20 packages that depend on Microsoft.Graph.
Packages | Downloads |
---|---|
Microsoft.Identity.Web
This package enables ASP.NET Core Web apps and Web APIs to use the Microsoft identity platform (formerly Azure AD v2.0).
This package is specifically used for web applications, which sign-in users, and protected web APIs, which optionally call downstream web APIs.
|
7 |
Microsoft.Identity.Web
This package enables ASP.NET Core Web apps and Web APIs to use the Microsoft identity platform (formerly Azure AD v2.0).
This package is specifically used for web applications, which sign-in users, and protected web APIs, which optionally call downstream web APIs.
|
5 |
.NET 5.0
- Microsoft.Graph.Core (>= 3.1.10)
.NET Standard 2.0
- Microsoft.Graph.Core (>= 3.1.10)
.NET Standard 2.1
- Microsoft.Graph.Core (>= 3.1.10)
Version | Downloads | Last updated |
---|---|---|
5.62.0 | 3 | 11/08/2024 |
5.61.0 | 2 | 10/22/2024 |
5.60.0 | 0 | 10/09/2024 |
5.59.0 | 0 | 10/02/2024 |
5.58.0 | 0 | 09/12/2024 |
5.57.0 | 0 | 09/05/2024 |
5.56.1 | 2 | 10/12/2024 |
5.56.0 | 3 | 06/11/2024 |
5.55.0 | 3 | 06/02/2024 |
5.54.0 | 4 | 05/25/2024 |
5.53.0 | 5 | 05/21/2024 |
5.52.0 | 4 | 05/13/2024 |
5.51.0 | 4 | 05/05/2024 |
5.50.0 | 5 | 04/27/2024 |
5.49.0 | 5 | 04/19/2024 |
5.48.0 | 5 | 04/11/2024 |
5.47.0 | 8 | 04/08/2024 |
5.46.0 | 4 | 03/30/2024 |
5.45.0 | 7 | 04/08/2024 |
5.44.0 | 4 | 04/27/2024 |
5.43.0 | 4 | 04/27/2024 |
5.42.0 | 6 | 04/27/2024 |
5.41.0 | 4 | 04/27/2024 |
5.40.0 | 4 | 04/27/2024 |
5.39.0 | 4 | 04/27/2024 |
5.38.0 | 4 | 04/27/2024 |
5.37.0 | 4 | 04/27/2024 |
5.36.0 | 3 | 04/27/2024 |
5.35.0 | 3 | 04/27/2024 |
5.34.0 | 3 | 04/27/2024 |
5.33.0 | 4 | 04/27/2024 |
5.32.0 | 4 | 04/27/2024 |
5.31.0 | 4 | 04/27/2024 |
5.30.0 | 6 | 04/27/2024 |
5.29.0 | 5 | 04/27/2024 |
5.28.0 | 5 | 04/27/2024 |
5.27.0 | 5 | 04/27/2024 |
5.26.0 | 5 | 04/27/2024 |
5.25.0 | 3 | 04/27/2024 |
5.24.0 | 3 | 04/27/2024 |
5.23.0 | 3 | 04/27/2024 |
5.22.0 | 4 | 04/27/2024 |
5.21.0 | 5 | 04/27/2024 |
5.20.0 | 3 | 04/27/2024 |
5.19.0 | 4 | 04/27/2024 |
5.18.0 | 4 | 04/27/2024 |
5.17.0 | 8 | 04/27/2024 |
5.16.0 | 4 | 04/27/2024 |
5.15.0 | 6 | 04/27/2024 |
5.14.0 | 7 | 04/22/2024 |
5.13.0 | 4 | 04/27/2024 |
5.12.0 | 5 | 04/15/2024 |
5.11.0 | 4 | 04/27/2024 |
5.10.0 | 5 | 03/25/2024 |
5.9.0 | 3 | 04/27/2024 |
5.8.0 | 3 | 04/27/2024 |
5.7.0 | 4 | 04/27/2024 |
5.6.0 | 6 | 04/27/2024 |
5.5.0 | 4 | 04/27/2024 |
5.4.0 | 5 | 04/27/2024 |
5.3.0 | 7 | 04/08/2024 |
5.2.0 | 3 | 04/27/2024 |
5.1.0 | 4 | 04/27/2024 |
5.0.0 | 4 | 04/27/2024 |
5.0.0-rc.5 | 5 | 04/28/2024 |
5.0.0-rc.4 | 4 | 04/28/2024 |
5.0.0-rc.3 | 4 | 04/28/2024 |
5.0.0-rc.2 | 4 | 04/28/2024 |
5.0.0-rc.1 | 3 | 04/28/2024 |
5.0.0-preview.14 | 4 | 04/16/2024 |
5.0.0-preview.13 | 4 | 04/28/2024 |
5.0.0-preview.12 | 4 | 04/28/2024 |
5.0.0-preview.11 | 3 | 04/28/2024 |
5.0.0-preview.10 | 6 | 04/28/2024 |
5.0.0-preview.9 | 4 | 04/28/2024 |
5.0.0-preview.8 | 3 | 04/28/2024 |
5.0.0-preview.7 | 4 | 04/28/2024 |
5.0.0-preview.6 | 4 | 04/28/2024 |
5.0.0-preview.5 | 4 | 04/28/2024 |
5.0.0-preview.4 | 4 | 04/28/2024 |
5.0.0-preview.3 | 4 | 04/28/2024 |
5.0.0-preview.2 | 4 | 04/28/2024 |
5.0.0-preview.1 | 3 | 04/28/2024 |
4.54.0 | 3 | 06/24/2024 |
4.53.0 | 6 | 04/03/2024 |
4.52.0 | 4 | 04/27/2024 |
4.51.0 | 3 | 04/27/2024 |
4.50.0 | 3 | 04/27/2024 |
4.49.0 | 4 | 04/27/2024 |
4.48.0 | 4 | 04/27/2024 |
4.47.0 | 5 | 04/27/2024 |
4.46.0 | 4 | 04/27/2024 |
4.45.0 | 4 | 04/27/2024 |
4.44.0 | 5 | 04/27/2024 |
4.43.0 | 6 | 03/31/2024 |
4.42.0 | 6 | 04/24/2024 |
4.41.0 | 8 | 04/27/2024 |
4.40.0 | 3 | 04/27/2024 |
4.39.0 | 5 | 04/13/2024 |
4.38.0 | 5 | 04/27/2024 |
4.37.0 | 4 | 04/27/2024 |
4.36.0 | 5 | 04/15/2024 |
4.35.0 | 5 | 04/27/2024 |
4.34.0 | 4 | 04/27/2024 |
4.33.0 | 4 | 04/27/2024 |
4.32.0 | 4 | 04/27/2024 |
4.31.0 | 6 | 04/27/2024 |
4.30.0 | 5 | 04/27/2024 |
4.29.0 | 6 | 04/27/2024 |
4.28.0 | 3 | 04/27/2024 |
4.27.0 | 3 | 04/27/2024 |
4.26.0 | 4 | 04/27/2024 |
4.25.0 | 4 | 04/27/2024 |
4.24.0 | 5 | 04/26/2024 |
4.23.0 | 5 | 04/22/2024 |
4.22.0 | 3 | 04/27/2024 |
4.21.0 | 6 | 04/27/2024 |
4.20.0 | 4 | 04/27/2024 |
4.19.0 | 4 | 04/27/2024 |
4.18.0 | 4 | 04/27/2024 |
4.17.0 | 4 | 04/27/2024 |
4.16.0 | 3 | 04/27/2024 |
4.15.0 | 3 | 04/27/2024 |
4.14.0 | 4 | 04/27/2024 |
4.13.0 | 7 | 04/27/2024 |
4.12.0 | 5 | 04/27/2024 |
4.11.0 | 4 | 04/27/2024 |
4.10.0 | 5 | 04/27/2024 |
4.9.0 | 6 | 04/27/2024 |
4.8.0 | 3 | 04/27/2024 |
4.7.0 | 5 | 04/04/2024 |
4.6.0 | 4 | 04/27/2024 |
4.5.0 | 5 | 04/27/2024 |
4.4.0 | 4 | 04/27/2024 |
4.3.0 | 5 | 04/27/2024 |
4.2.0 | 4 | 04/27/2024 |
4.1.0 | 3 | 04/27/2024 |
4.0.0 | 4 | 04/27/2024 |
4.0.0-preview.7 | 4 | 04/28/2024 |
4.0.0-preview.6 | 3 | 04/28/2024 |
4.0.0-preview.5 | 3 | 04/28/2024 |
4.0.0-preview.4 | 4 | 04/28/2024 |
4.0.0-preview.3 | 4 | 04/28/2024 |
4.0.0-preview.2 | 4 | 04/28/2024 |
4.0.0-preview.1 | 4 | 04/28/2024 |
3.35.0 | 5 | 04/27/2024 |
3.34.0 | 3 | 04/27/2024 |
3.33.0 | 3 | 04/27/2024 |
3.32.0 | 4 | 04/27/2024 |
3.31.0 | 4 | 04/27/2024 |
3.30.0 | 7 | 04/21/2024 |
3.29.0 | 6 | 04/07/2024 |
3.28.0 | 4 | 04/27/2024 |
3.27.0 | 4 | 04/27/2024 |
3.26.0 | 4 | 04/27/2024 |
3.25.0 | 4 | 04/27/2024 |
3.24.0 | 4 | 04/28/2024 |
3.23.0 | 4 | 04/28/2024 |
3.22.0 | 4 | 04/27/2024 |
3.21.0 | 4 | 04/28/2024 |
3.20.0 | 3 | 04/28/2024 |
3.19.0 | 4 | 04/28/2024 |
3.18.0 | 4 | 04/28/2024 |
3.17.0 | 5 | 04/28/2024 |
3.16.0 | 4 | 04/28/2024 |
3.15.0 | 4 | 04/28/2024 |
3.14.0 | 4 | 04/28/2024 |
3.13.0 | 4 | 04/28/2024 |
3.12.0 | 4 | 04/28/2024 |
3.11.0 | 4 | 04/28/2024 |
3.10.0 | 4 | 04/28/2024 |
3.9.0 | 5 | 04/06/2024 |
3.8.0 | 4 | 04/27/2024 |
3.7.0 | 5 | 04/27/2024 |
3.6.0 | 6 | 03/28/2024 |
3.5.0 | 5 | 04/27/2024 |
3.4.0 | 4 | 04/27/2024 |
3.3.0 | 6 | 04/27/2024 |
3.2.0 | 4 | 04/27/2024 |
3.1.0 | 6 | 04/27/2024 |
3.0.1 | 5 | 04/27/2024 |
1.21.0 | 5 | 04/28/2024 |
1.20.0 | 5 | 04/24/2024 |
1.19.0 | 4 | 04/28/2024 |
1.18.0 | 5 | 04/28/2024 |
1.17.0 | 5 | 04/28/2024 |
1.16.0 | 7 | 04/28/2024 |
1.15.0 | 7 | 04/28/2024 |
1.14.0 | 6 | 04/28/2024 |
1.14.0-preview | 6 | 04/28/2024 |
1.13.0-preview | 4 | 04/28/2024 |
1.12.0 | 4 | 04/28/2024 |
1.11.0 | 4 | 04/28/2024 |
1.10.0 | 4 | 04/28/2024 |
1.9.0 | 4 | 04/27/2024 |
1.8.1 | 5 | 04/27/2024 |
1.7.0 | 4 | 04/27/2024 |
1.6.2 | 4 | 04/27/2024 |
1.6.1 | 3 | 04/27/2024 |
1.6.0 | 4 | 04/27/2024 |
1.5.1 | 5 | 04/25/2024 |
1.5.0 | 4 | 04/27/2024 |
1.4.0 | 5 | 04/27/2024 |
1.3.0 | 3 | 04/27/2024 |
1.2.1 | 4 | 04/27/2024 |
1.2.0 | 5 | 04/23/2024 |
1.1.1 | 4 | 04/27/2024 |
1.0.1 | 4 | 04/27/2024 |
1.0.0 | 4 | 04/27/2024 |
0.2.8-rc | 3 | 04/28/2024 |