Microsoft Graph API
Overview of Microsoft Graph

What is the Microsoft Graph?

Microsoft Graph provides a unified programmability model that you can use to build apps for organizations and consumers that interact with the data of millions of users. With Microsoft Graph, you can connect to a wealth of resources, relationships, and intelligence, all through a single endpoint: https://graph.microsoft.com.

Microsoft Graph enables you to integrate with the best of Office 365, Windows 10, and Enterprise Mobility and Security services in Microsoft 365, using REST APIs and client libraries. Additionally, it offers security and social intelligence that can boost user productivity, creativity, and team collaboration, and protect business resources and users' data.

Consider the following steps involved while dealing with different Office 365 APIs in an application:

  • Find the URL/endpoint of the API

  • Authenticate/get an access token

  • Get results from the API

  • Repeat for each service

  • Manage multiple tokens for each API

Microsoft Graph SDK for Java

Why an SDK?

Users can begin developing immediately by connecting with the REST API directly if they desire. If you are interested in diving right into Graph data, the SDK provides a few shortcuts:

        1. HTTP logic is written for you so you reduce the amount of boilerplate you need to get started.
        2. The SDK gives you access to POJOs that you can use to access and update instead of working directly with JSON.
        3. An extra layer of error handling and intelligent defaults help you debug your application.
        4. Request builders make it easy for you to discover the paths through which you can access the rich data stores in Graph.
        5. Helpers for Graph functionality, such as pagination and webhooks, as well as workload-specific helpers for products, such as OneNote and Planner, simplify accomplishing specific scenarios.

Using the SDK with an Authentication Library

Currently, the SDK does not handle authentication against Azure Active Directory. You need to select an OAuth2 package that suits your authentication needs. First-party auth libraries are available from Azure AD:

1. MSAL: Microsoft Authentication Library - supports converged auth for both consumer and business accounts (Android)
2. ADAL: Azure Active Directory Library - supports v1 auth for business accounts.