Microsoft.Graph.Core 3.2.1

Prefix Reserved
dotnet add package Microsoft.Graph.Core --version 3.2.1                
NuGet\Install-Package Microsoft.Graph.Core -Version 3.2.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Graph.Core" Version="3.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.Graph.Core --version 3.2.1                
#r "nuget: Microsoft.Graph.Core, 3.2.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.Graph.Core as a Cake Addin
#addin nuget:?package=Microsoft.Graph.Core&version=3.2.1

// Install Microsoft.Graph.Core as a Cake Tool
#tool nuget:?package=Microsoft.Graph.Core&version=3.2.1                

Microsoft Graph .NET Core Client Library

Build Status NuGet Version

Integrate the Microsoft Graph API into your .NET project!

The Microsoft Graph .NET Core Client Library contains core classes and interfaces used by Microsoft.Graph Client Library to send native HTTP requests to Microsoft Graph API. The latest core client library targets .NetStandard 2.0.

Installation via NuGet

To install the client library via NuGet:

  • Search for Microsoft.Graph.Core in the NuGet Library, or
  • Type Install-Package Microsoft.Graph.Core into the Package Manager Console.

Getting started

1. Register your application

Register your application to use Microsoft Graph API by following the steps at Register your application with the Microsoft identity platform.

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 HttpClient object with an authentication provider

You can create an instance of HttpClient that is pre-configured for making requests to Microsoft Graph APIs using GraphClientFactory.

// The client credentials flow requires that you request the
// /.default scope, and pre-configure your permissions on the
// app registration in Azure. An administrator must grant consent
// to those permissions beforehand.
var scopes = new[] { "https://graph.microsoft.com/.default" };

// Values from app registration
var clientId = "YOUR_CLIENT_ID";
var tenantId = "YOUR_TENANT_ID";
var clientSecret = "YOUR_CLIENT_SECRET";

// using Azure.Identity;
var options = new ClientSecretCredentialOptions
{
    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
};

// https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential
var clientSecretCredential = new ClientSecretCredential(
    tenantId, clientId, clientSecret, options);

HttpClient httpClient = GraphClientFactory.create(tokenCredential: clientSecretCredential, version: "beta");

For more information on initializing a client instance, see the library overview

4. Make requests to the graph

Once you have an authenticated HttpClient, you can begin to make calls to the service. The requests to the service follows our REST API syntax.

For example, to retrieve a user's default drive:

HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, "me/drive");
HttpResponseMessage response = await httpClient.SendAsync(requestMessage);
if (response.IsSuccessStatusCode)
{
    string jsonResponse = await response.Content.ReadAsStringAsync();
}

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

HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, "me/drive/root");
HttpResponseMessage response = await httpClient.SendAsync(requestMessage);
if (response.IsSuccessStatusCode)
{
    string jsonResponse = await response.Content.ReadAsStringAsync();
}

Documentation and resources

Notes

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.

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

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

Run dotnet build -p:IncludeMauiTargets=true if you wish to build the MAUI targets for the projects as well.

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.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (39)

Showing the top 5 NuGet packages that depend on Microsoft.Graph.Core:

Package Downloads
Microsoft.Graph

Microsoft Graph Client Library allows you to call Office 365, Azure AD and other Microsoft services through a single unified developer experience.

Microsoft.Graph.Auth

Microsoft Graph Authentication Library implements authentication functionality used by Microsoft Graph Client Library. It provides a set of OAuth scenario-centric providers that implement Microsoft.Graph.IAuthenticationProvider and uses Microsoft Authentication Library (MSAL) to handle access token acquisition and storage.

Microsoft.Graph.Beta

Microsoft Graph beta client library allows you to target the Microsoft Graph /beta endpoint. You can call Office 365, Azure AD and other Microsoft services through a single unified developer experience.

PnP.Framework

PnP Framework contains the PnP Provisioning engine and a ton of extension methods that will make you more productive while developing for Microsoft 365.

Microsoft.Graph.Communications.Core

Microsoft Graph Communications Client Core Library - This library builds on the Microsoft.Graph SDK to provide better support for the Communications APIs.

GitHub repositories (25)

Showing the top 5 popular GitHub repositories that depend on Microsoft.Graph.Core:

Repository Stars
ONLYOFFICE/CommunityServer
Free open source office suite with business productivity tools: document and project management, CRM, mail aggregator.
pnp/PnP
SharePoint / Office 365 Developer Patterns and Practices - Archived older solutions. Please see https://aka.ms/m365pnp for updated guidance
OfficeDev/Microsoft-Teams-Samples
Welcome to the Microsoft Teams samples repository. Here you will find task-focused samples in C#, JavaScript and TypeScript to help you get started with the Microsoft Teams App!
pnp/PnP-PowerShell
SharePoint PnP PowerShell CmdLets
microsoftgraph/msgraph-sdk-powershell
Powershell SDK for Microsoft Graph
Version Downloads Last updated
3.2.1 487,582 11/20/2024
3.2.0 21,681 11/8/2024
3.1.22 1,805,431 9/26/2024
3.1.21 683,646 9/4/2024
3.1.20 27,060 8/28/2024
3.1.19 312,064 8/26/2024
3.1.18 1,343 8/26/2024
3.1.17 18,747 8/19/2024
3.1.16 5,876 8/15/2024
3.1.15 30,286 8/9/2024
3.1.14 52,998 7/24/2024
3.1.13 88,691 7/3/2024
3.1.12 4,390,221 5/28/2024
3.1.11 1,163,578 4/30/2024
3.1.10 1,285,992 3/28/2024
3.1.9 561,302 3/18/2024
3.1.8 1,511,687 2/16/2024
3.1.8-preview.1 128 2/27/2024
3.1.7 324,553 2/9/2024
3.1.6 1,950,201 1/23/2024
3.1.5 378,216 1/15/2024
3.1.4 42,539 1/9/2024
3.1.3 1,108,249 11/29/2023
3.1.2 1,250,254 11/15/2023
3.1.1 241,518 11/7/2023
3.1.0 383,161 10/24/2023
3.0.11 1,251,240 9/5/2023
3.0.11-preview.1 250 9/1/2023
3.0.10 839,606 8/8/2023
3.0.10-preview.1 743 7/13/2023
3.0.9 1,076,791 6/29/2023
3.0.9-preview.1 228 6/29/2023
3.0.8 10,385 6/27/2023
3.0.7 705,760 5/30/2023
3.0.6 1,376,713 4/18/2023
3.0.6-preview.1 212 4/18/2023
3.0.5 665,566 3/30/2023
3.0.4 165,679 3/27/2023
3.0.3 218,469 3/21/2023
3.0.2 172,509 3/13/2023
3.0.1 140,377 3/7/2023
3.0.0 209,196 2/28/2023
3.0.0-rc.6 9,483 2/9/2023
3.0.0-rc.5 4,496 1/26/2023
3.0.0-rc.4 297 1/25/2023
3.0.0-rc.3 3,962 1/18/2023
3.0.0-rc.2 1,872 1/11/2023
3.0.0-rc.1 12,560 12/16/2022
3.0.0-preview.19 299 12/14/2022
3.0.0-preview.18 461 12/6/2022
3.0.0-preview.17 102,222 11/23/2022
3.0.0-preview.16 124,485 10/18/2022
3.0.0-preview.15 485 10/3/2022
3.0.0-preview.14 7,433 9/28/2022
3.0.0-preview.13 2,467 9/6/2022
3.0.0-preview.12 479 8/29/2022
3.0.0-preview.11 83,584 7/20/2022
3.0.0-preview.10 2,338 7/13/2022
3.0.0-preview.9 21,980 6/21/2022
3.0.0-preview.8 2,143 6/9/2022
3.0.0-preview.7 1,568 5/31/2022
3.0.0-preview.6 6,190 5/20/2022
3.0.0-preview.5 13,956 5/4/2022
3.0.0-preview.4 4,055 4/13/2022
3.0.0-preview.3 375 4/12/2022
3.0.0-preview.2 1,812 4/1/2022
3.0.0-preview.1 2,377 3/22/2022
2.0.15 4,679,040 2/9/2023
2.0.14 9,121,121 10/11/2022
2.0.13 1,001,896 9/27/2022
2.0.13-preview.1 280 9/26/2022
2.0.12 3,741,463 8/24/2022
2.0.11 2,150,617 8/11/2022
2.0.10 980,176 7/20/2022
2.0.9 5,253,583 6/9/2022
2.0.8 6,038,198 2/18/2022
2.0.7 3,956,380 12/16/2021
2.0.6 320,638 12/2/2021
2.0.5 7,062,815 9/1/2021
2.0.4 54,896 8/24/2021
2.0.3 416,070 8/17/2021
2.0.2 762,765 8/11/2021
2.0.1 183,302 8/5/2021
2.0.0 571,894 7/22/2021
2.0.0-preview.14 2,543 7/7/2021
2.0.0-preview.13 47,215 6/18/2021
2.0.0-preview.12 44,968 6/7/2021
2.0.0-preview.11 62,333 5/7/2021
2.0.0-preview.10 46,989 4/21/2021
2.0.0-preview.9 25,384 4/1/2021
2.0.0-preview.8 40,486 3/17/2021
2.0.0-preview.7 628 3/2/2021
2.0.0-preview.6 486 2/24/2021
2.0.0-preview.5 365 2/24/2021
2.0.0-preview.4 5,161 1/6/2021
2.0.0-preview.3 29,512 4/29/2020
2.0.0-preview.2 2,561 4/9/2020
2.0.0-preview.1 16,677 3/9/2020
1.25.1 12,137,828 3/25/2021
1.25.1-preview.2 356 3/25/2021
1.25.1-preview.1 371 3/25/2021
1.25.0 291,089 3/25/2021
1.25.0-preview.2 384 3/20/2021
1.25.0-preview.1 587 3/17/2021
1.24.0 3,488,999 1/19/2021
1.24.0-preview.1 375 1/14/2021
1.23.0 3,061,817 11/26/2020
1.22.0 3,551,007 10/7/2020
1.22.0-preview.2 460 10/6/2020
1.22.0-preview.1 468 7/28/2020
1.21.0 4,518,690 7/28/2020
1.21.0-preview.1 3,117 6/19/2020
1.20.1 5,691,740 3/31/2020
1.20.0 7,628,888 2/5/2020
1.19.0 2,918,763 12/11/2019
1.18.0 1,442,944 10/10/2019
1.17.0 948,664 8/15/2019
1.16.0 129,709 7/3/2019
1.15.0 2,308,896 5/1/2019
1.14.1 168,171 3/29/2019
1.14.0 1,422,826 3/25/2019
1.12.0 1,396,475 10/31/2018
1.11.0 319,285 9/19/2018
1.10.0 426,631 7/6/2018
1.9.0 1,734,186 5/3/2018
1.8.1 221,836 3/23/2018
1.7.0 203,759 12/14/2017
1.6.2 171,008 9/26/2017
1.6.1 84,926 8/24/2017
1.6.0 52,401 8/8/2017
1.5.0 257,844 6/12/2017
1.4.0 312,181 5/10/2017
1.3.1 75,568 4/3/2017
1.3.0 212,519 11/8/2016
1.2.1 146,543 9/27/2016
1.1.1 12,330 8/8/2016
1.1.0 5,441 8/6/2016