From 6d594a958c034796e2c2c3197825856fbd7781e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:04:46 +0000 Subject: [PATCH 1/5] Bump com.microsoft.graph:microsoft-graph in /src/app Bumps [com.microsoft.graph:microsoft-graph](https://github.com/microsoftgraph/msgraph-sdk-java) from 5.80.0 to 6.71.0. - [Release notes](https://github.com/microsoftgraph/msgraph-sdk-java/releases) - [Changelog](https://github.com/microsoftgraph/msgraph-sdk-java/blob/main/CHANGELOG.md) - [Commits](https://github.com/microsoftgraph/msgraph-sdk-java/compare/v5.80.0...v6.71.0) --- updated-dependencies: - dependency-name: com.microsoft.graph:microsoft-graph dependency-version: 6.71.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- src/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/build.gradle b/src/app/build.gradle index b0a59dc..97b1929 100644 --- a/src/app/build.gradle +++ b/src/app/build.gradle @@ -38,7 +38,7 @@ dependencies { implementation 'com.google.android.material:material:1.7.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.microsoft.identity.client:msal:8.5.0' - implementation 'com.microsoft.graph:microsoft-graph:5.80.0' + implementation 'com.microsoft.graph:microsoft-graph:6.71.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' From 7d1d65b41bafd2d9ddc3815688890bcbf4985b5b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:13:12 +0000 Subject: [PATCH 2/5] Restore compatible Microsoft Graph SDK version Co-authored-by: jasonjoh <8966342+jasonjoh@users.noreply.github.com> --- src/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/build.gradle b/src/app/build.gradle index 97b1929..b0a59dc 100644 --- a/src/app/build.gradle +++ b/src/app/build.gradle @@ -38,7 +38,7 @@ dependencies { implementation 'com.google.android.material:material:1.7.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'com.microsoft.identity.client:msal:8.5.0' - implementation 'com.microsoft.graph:microsoft-graph:6.71.0' + implementation 'com.microsoft.graph:microsoft-graph:5.80.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' From 91ac288367bcd76f8dfe3cd2b966278a533abf5e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:17:59 +0000 Subject: [PATCH 3/5] Migrate sample to Graph SDK v6 Co-authored-by: jasonjoh <8966342+jasonjoh@users.noreply.github.com> --- .../graphsample/AuthenticationHelper.java | 30 ++-- .../example/graphsample/EventListAdapter.java | 15 +- .../com/example/graphsample/GraphHelper.java | 131 ++++++++---------- .../com/example/graphsample/MainActivity.java | 9 +- 4 files changed, 89 insertions(+), 96 deletions(-) diff --git a/src/app/src/main/java/com/example/graphsample/AuthenticationHelper.java b/src/app/src/main/java/com/example/graphsample/AuthenticationHelper.java index 7b251b8..aa4ca4d 100644 --- a/src/app/src/main/java/com/example/graphsample/AuthenticationHelper.java +++ b/src/app/src/main/java/com/example/graphsample/AuthenticationHelper.java @@ -9,7 +9,9 @@ import androidx.annotation.NonNull; -import com.microsoft.graph.authentication.BaseAuthenticationProvider; +import com.microsoft.kiota.RequestInformation; +import com.microsoft.kiota.authentication.AllowedHostsValidator; +import com.microsoft.kiota.authentication.AuthenticationProvider; import com.microsoft.identity.client.AuthenticationCallback; import com.microsoft.identity.client.IAuthenticationResult; import com.microsoft.identity.client.IPublicClientApplication; @@ -18,14 +20,18 @@ import com.microsoft.identity.client.SignInParameters; import com.microsoft.identity.client.exception.MsalException; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import java.util.Arrays; +import java.util.Map; import java.util.concurrent.CompletableFuture; // Singleton class - the app only needs a single instance // of PublicClientApplication -public class AuthenticationHelper extends BaseAuthenticationProvider { +public class AuthenticationHelper implements AuthenticationProvider { private static AuthenticationHelper INSTANCE = null; + private static final AllowedHostsValidator ALLOWED_HOSTS = + new AllowedHostsValidator("graph.microsoft.com"); private ISingleAccountPublicClientApplication mPCA = null; private final String[] mScopes = { "User.Read", "MailboxSettings.Read", "Calendars.ReadWrite" }; @@ -147,15 +153,17 @@ public void onError(MsalException exception) { }; } - @NonNull @Override - public CompletableFuture getAuthorizationTokenAsync(@NonNull URL requestUrl) { - if (shouldAuthenticateRequestWithUrl(requestUrl)) { - return acquireTokenSilently() - .thenApply(IAuthenticationResult::getAccessToken); + public void authenticateRequest(@NonNull RequestInformation request, + Map additionalAuthenticationContext) { + try { + URI requestUri = request.getUri(); + if (requestUri != null && ALLOWED_HOSTS.isUrlHostValid(requestUri)) { + String accessToken = acquireTokenSilently().join().getAccessToken(); + request.headers.tryAdd("Authorization", "Bearer " + accessToken); + } + } catch (URISyntaxException exception) { + throw new IllegalArgumentException("Unable to parse request URL", exception); } - - return CompletableFuture.completedFuture(null); } } - diff --git a/src/app/src/main/java/com/example/graphsample/EventListAdapter.java b/src/app/src/main/java/com/example/graphsample/EventListAdapter.java index 337790f..cdfc1ed 100644 --- a/src/app/src/main/java/com/example/graphsample/EventListAdapter.java +++ b/src/app/src/main/java/com/example/graphsample/EventListAdapter.java @@ -60,11 +60,12 @@ public View getView(int position, View convertView, ViewGroup parent) { holder = (ViewHolder) convertView.getTag(); } - holder.subject.setText(event.subject); - Objects.requireNonNull(event.organizer); - holder.organizer.setText(Objects.requireNonNull(event.organizer.emailAddress).name); - holder.start.setText(getLocalDateTimeString(Objects.requireNonNull(event.start))); - holder.end.setText(getLocalDateTimeString(Objects.requireNonNull(event.end))); + holder.subject.setText(event.getSubject()); + Objects.requireNonNull(event.getOrganizer()); + holder.organizer.setText( + Objects.requireNonNull(event.getOrganizer().getEmailAddress()).getName()); + holder.start.setText(getLocalDateTimeString(Objects.requireNonNull(event.getStart()))); + holder.end.setText(getLocalDateTimeString(Objects.requireNonNull(event.getEnd()))); return convertView; } @@ -73,8 +74,8 @@ public View getView(int position, View convertView, ViewGroup parent) { // a LocalDateTime, then return a formatted string @NonNull private String getLocalDateTimeString(@NonNull DateTimeTimeZone dateTime) { - ZonedDateTime localDateTime = LocalDateTime.parse(dateTime.dateTime) - .atZone(GraphToIana.getZoneIdFromWindows(dateTime.timeZone)); + ZonedDateTime localDateTime = LocalDateTime.parse(dateTime.getDateTime()) + .atZone(GraphToIana.getZoneIdFromWindows(dateTime.getTimeZone())); return String.format("%s %s", localDateTime.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)), diff --git a/src/app/src/main/java/com/example/graphsample/GraphHelper.java b/src/app/src/main/java/com/example/graphsample/GraphHelper.java index 0982500..14d939f 100644 --- a/src/app/src/main/java/com/example/graphsample/GraphHelper.java +++ b/src/app/src/main/java/com/example/graphsample/GraphHelper.java @@ -11,14 +11,10 @@ import com.microsoft.graph.models.DateTimeTimeZone; import com.microsoft.graph.models.EmailAddress; import com.microsoft.graph.models.Event; +import com.microsoft.graph.models.EventCollectionResponse; import com.microsoft.graph.models.ItemBody; import com.microsoft.graph.models.User; -import com.microsoft.graph.options.HeaderOption; -import com.microsoft.graph.options.Option; -import com.microsoft.graph.options.QueryOption; -import com.microsoft.graph.requests.EventCollectionPage; -import com.microsoft.graph.requests.EventCollectionRequestBuilder; -import com.microsoft.graph.requests.GraphServiceClient; +import com.microsoft.graph.serviceclient.GraphServiceClient; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -26,19 +22,16 @@ import java.util.List; import java.util.concurrent.CompletableFuture; -import okhttp3.Request; - // Singleton class - the app only needs a single instance // of the Graph client public class GraphHelper { private static GraphHelper INSTANCE = null; - private final GraphServiceClient mClient; + private final GraphServiceClient mClient; private GraphHelper() { AuthenticationHelper authProvider = AuthenticationHelper.getInstance(); - mClient = GraphServiceClient.builder() - .authenticationProvider(authProvider).buildClient(); + mClient = new GraphServiceClient(authProvider); } public static synchronized GraphHelper getInstance() { @@ -51,59 +44,50 @@ public static synchronized GraphHelper getInstance() { public CompletableFuture getUser() { // GET /me (logged in user) - return mClient.me().buildRequest() - .select("displayName,mail,mailboxSettings,userPrincipalName") - .getAsync(); + return CompletableFuture.supplyAsync(() -> mClient.me().get(requestConfiguration -> + requestConfiguration.queryParameters.select = new String[] { + "displayName", "mail", "mailboxSettings", "userPrincipalName" + })); } public CompletableFuture> getCalendarView(ZonedDateTime viewStart, ZonedDateTime viewEnd, String timeZone) { - final List