Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
February 24, 2022 14:38
September 13, 2021 14:09
September 29, 2023 15:07
December 29, 2020 08:57
October 22, 2018 12:37
April 27, 2021 10:33
April 17, 2023 12:34
April 17, 2023 12:34

Microsoft Graph SDK for Java


Get started with the Microsoft Graph SDK for Java by integrating the Microsoft Graph API into your Java application!

Note: this SDK allows you to build applications using the v1.0 of Microsoft Graph. If you want to try the latest Microsoft Graph APIs under beta, use our beta SDK instead.

1. Installation

1.1 Install via Gradle

Add the repository and a compile dependency for microsoft-graph to your project's build.gradle:

repositories {

dependencies {
    // Include the sdk as a dependency
    implementation 'com.microsoft.graph:microsoft-graph:5.72.0'
    // Uncomment the line below if you are building an android application
    //implementation 'com.google.guava:guava:30.1.1-android'
    // This dependency is only needed if you are using the TokenCrendentialAuthProvider
    implementation 'com.azure:azure-identity:1.2.5'

1.2 Install via Maven

Add the dependency in dependencies in pom.xml

  <!-- Include the sdk as a dependency -->
  <!-- This dependency is only needed if you are using the TokenCredentialAuthProvider -->

1.3 Enable ProGuard (Android)

The nature of the Graph API is such that the SDK needs quite a large set of classes to describe its functionality. You need to ensure that ProGuard is enabled on your project. Otherwise, you will incur long build times for functionality that is not necessarily relevant to your particular application. If you are still hitting the 64K method limit, you can also enable multidexing. Checkout the recommended rules.

2. Getting started

2.1 Register your application

Register your application by following the steps at Register your app with the Microsoft Identity Platform.

2.2 Create an IAuthenticationProvider object

An instance of the GraphServiceClient class handles building requests, sending them to the 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 an example of how to get an authentication provider, see choose a Microsoft Graph authentication provider.

2.3 Get a GraphServiceClient object

After you have set the correct application ID and URL, you must get a GraphServiceClient object to make requests against the service. The SDK stores the account information for you, but when a user signs in for the first time, it invokes the UI to get the user's account information.

GraphServiceClient<Request> graphClient = 

3. Make requests against the service

After you have a GraphServiceClient that is authenticated, you can begin making calls against the service. The requests against the service look like our REST API.

3.1 Get the user's drive

To retrieve the user's drive:

final Drive result = graphClient
System.out.println("Found Drive " + result.id);

Or with the asynchronous API.

  .thenApply(result -> {
    System.out.println("Found Drive " + result.id);

4. Documentation

For more detailed documentation, see:

5. Issues

For known issues, see issues.

6. Contributions

The Microsoft Graph SDK is open for contribution. To contribute to this project, see Contributing.

7. Supported Java versions

The Microsoft Graph SDK for Java library is supported at runtime for Java 8+ and Android API revision 26 and greater.

8. License

Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.

9. Third-party notices

Third-party notices