Skip to content
Microsoft Graph Client Library for .NET!
Branch: dev
Clone or download

Latest commit

zengin Merge pull request #705 from microsoftgraph/zengin/fixCopyright
Fix powershell script to not introduce unwanted character in front of copyright
Latest commit 0327251 May 28, 2020


Type Name Latest commit message Commit time
Failed to load latest commit information.
.azure-pipelines Pipeline for generating service library (#650) Mar 25, 2020
.github Generated models and request builders using Typewriter (#670) Apr 14, 2020
README-Localized HB of localized readme files (#641) Mar 19, 2020
build Microsoft Graph .NET Client Library Mar 29, 2016
docs Bearer in Auth header needs to be capitalized (#562) Oct 23, 2019
scripts fix powershell script to not introduce unwanted character in front of… May 28, 2020
src/Microsoft.Graph Generated v1.0 models and request builders using Typewriter (#694) May 21, 2020
tests/Microsoft.Graph.DotnetCore.Test Generated models and request builders using Typewriter (#647) Mar 16, 2020
.gitignore July update 2018 - Add Activity API PUT functionality (#288) Jul 7, 2018 Added contribution file. Dec 1, 2017
LICENSE.txt Update LICENSE.txt Apr 19, 2019
Microsoft.Graph.sln Remove Microsoft.Graph.Core project and tests from solution. May 21, 2019 Updated readme to link post describing version bump, updated targets (#… May 5, 2020
THIRD PARTY NOTICES Add information on third party packages Feb 15, 2018
appveyor.yml Feature/date timezone extensions (#555) Oct 15, 2019
msgraph-sdk-dotnet.yml Create msgraph-sdk-dotnet.yml (#614) Mar 19, 2020

Microsoft Graph .NET Client Library

Build status NuGet Version

Integrate the Microsoft Graph API into your .NET project!

The Microsoft Graph .NET Client Library targets .NetStandard 2.0 and .Net Framework 4.6.1.

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 does not currently include any default authentication implementations. There are set of preview authentication providers available in the msgraph-sdk-dotnet-auth repo. Alternatively, you can use the built-in DelegateAuthenticationProvider class to authenticate each request. For more information on DelegateAuthenticationProvider, see the library overview.

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.Request().GetAsync();

GetAsync will return a Drive object on success and throw a ServiceException on error.

To get the current user's root folder of their default drive:

var rootItem = await graphClient.Me.Drive.Root.Request().GetAsync();

GetAsync will return a DriveItem object on success and throw a ServiceException on error.

For a general overview of how the SDK is designed, see overview.

The following sample applications are also available:

Documentation and resources


Install NewtonSoft.Json first if you want to use a version greater than NewtonSoft.Json 6.0.1. For example, you'll need to install NewtonSoft.Json 9.0.1 first if you want to use this to library while targeting .Net Core with standard1.0.

Install System.Runtime.InteropServices.RuntimeInformation before you install Microsoft.Graph >=1.3 if you are having an issue updating the package for a Xamarin solution. You may need to updated references to Microsoft.NETCore.UniversalWindowsPlatform to >=5.2.2 as well.


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 with any additional questions or comments.

Other resources

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 and msbuild from CLI or run Build from Visual Studio to restore Nuget packages and build the project


Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license. See Third Party Notices for information on the packages referenced via NuGet.

You can’t perform that action at this time.