The library provides a convenient abstraction layer over the Microsoft Graph SDK, simplifying interactions with Microsoft Graph APIs. By wrapping the Microsoft Graph SDK, the library offers a consistent and simplified interface, handling complexities like paging and error handling for you.
- Introduction
- Table of Contents
- Atc.Microsoft.Graph.Client
- Sample Project
- Requirements
- How to Contribute
The services provided in the Atc.Microsoft.Graph.Client
package are designed to facilitate seamless interaction with various Microsoft services through the Graph API. These services are essential for applications that need to manage and retrieve data efficiently from OneDrive, Outlook, SharePoint, Teams, User Management etc. By leveraging these services, applications can ensure robust and secure handling of data, integrating comprehensive functionalities directly into the application's workflow. Each service supports efficient querying of data, supporting expand, filter, and select query parameters to tailor the data retrieval process.
The IOneDriveGraphService
is essential for applications that require efficient management of OneDrive resources, including retrieving and managing drives and drive items, tracking changes with delta tokens, and downloading files. This service ensures robust and secure handling of OneDrive data, integrating OneDrive capabilities directly into the application's workflow.
The IOutlookGraphService
is essential for applications that need to manage and retrieve Outlook mail data, such as mail folders, messages, and file attachments. It enables efficient querying of mail folders and messages, supports the use of delta tokens for tracking changes, and ensures secure handling of email data, enhancing email management within the application's ecosystem.
The ISharepointGraphService
is essential for applications that need to manage SharePoint sites and subscriptions effectively. It provides capabilities for retrieving site information, setting up and managing subscriptions, and handling subscription renewals and deletions, ensuring robust and efficient integration of SharePoint functionalities within the application's environment.
The ITeamsGraphService is essential for applications that need to retrieve and manage information about Teams. It allows for efficient querying of Teams data, enhancing collaboration and communication capabilities within the application's ecosystem.
The IUsersGraphService
is essential for applications that need to retrieve and manage information about users. It allows for efficient querying of user data, ensuring robust and efficient integration of user management functionalities within the application's environment.
To seamlessly integrate the Graph services into your application, you can utilize the provided ServiceCollection
extension methods. These methods simplify the setup process and ensure that the Graph services are correctly configured and ready to use within your application's service architecture.
The methods ensure that the Graph services are added to the application's service collection and configured according to the specified parameters, making them available throughout your application via dependency injection.
The configuration example below utilize the application's settings (typically defined in appsettings.json) to configure the Graph Services by calling the overload that accepts GraphServiceOptions
and implicitly configures the GraphServiceClient utilizing a ClientSecretCredential.
The ServiceCollectionExtensions
class provides several methods to add and configure the Graph services in your application:
-
AddMicrosoftGraphServices(GraphServiceClient? graphServiceClient = null)
Adds the GraphServiceClient to the service collection, optionally using a provided GraphServiceClient instance. If no instance is provided, one must be available in the service provider when this service is resolved.
-
AddMicrosoftGraphServices(TokenCredential tokenCredential, string[]? scopes = null)
Adds the GraphServiceClient to the service collection using the provided TokenCredential for authentication. Optional scopes can also be specified.
-
AddMicrosoftGraphServices(GraphServiceOptions graphServiceOptions, string[]? scopes = null)
Adds the GraphServiceClient to the service collection using the provided GraphServiceOptions. This method ensures the GraphServiceClient is configured with a ClientSecretCredential based on the specified options.
public void ConfigureServices(IServiceCollection services)
{
var graphServiceOptions = new GraphServiceOptions
{
TenantId = "your_tenant_id",
ClientId = "your_client_id",
ClientSecret = "your_client_secret",
};
services.AddMicrosoftGraphServices(graphServiceOptions);
}
A sample is included, demonstrating how to configure and use the Microsoft Graph services.