Microsoft Graph REST API
Microsoft Graph can be accessed via two primary approaches: REST APIs or SDKs.REST APIs Overview
When using REST APIs, the endpoint follows this structure:- HTTP Method: Specifies the action (e.g., GET, POST, PATCH, PUT, DELETE).
- Version: Use “v1.0” for stable releases or “beta” for preview features.
- Resource: The target entity (e.g., users, groups, drives, devices) along with its associated properties.
- Query Parameters: (Optional) Enhance query results with filters like
$filterand$selectto choose specific fields.
Microsoft Graph SDK
While the REST API offers direct access, the Microsoft Graph SDK simplifies development by abstracting REST calls into object-oriented methods.Key Components of the Microsoft Graph SDK
- Microsoft Graph Library: Provides an object-oriented mapping that converts REST APIs into corresponding classes.
- Core SDK Functions: Encapsulate functions to call Microsoft Graph endpoints, offering high-level methods for data retrieval.
- Authentication: Utilizes authentication providers integrated with the Microsoft Authentication Library (MSAL) for secure token management.


Example: Setting Up the SDK
Below is an example of how to build a Microsoft Graph client using the SDK, configuring the authentication provider, and querying the API for user profile details.The following example demonstrates the creation of a GraphServiceClient that leverages device code authentication to access specific user details.
Complete Sample in Visual Studio Code
The following complete example demonstrates how to use Public Client Application Builder with a device code flow to acquire an access token and make a Graph API call:App Registration Considerations
Before using the service principal or app registration, ensure that the authentication settings in your Azure portal app registration are correctly configured for device code flow.Ensure that the device code flow setting is enabled in your app registration configuration. Failing to do so will cause the authentication process to fail.
