Share via

Issue with Microsoft GraphClient while fetching Entra Id Users information

Kumar Sugandh 70 Reputation points
2026-04-22T18:13:21.66+00:00

Hi,

We have two instances of same app running in parallel using same Oauth2 credentials for the Microsoft Entra Id app for pulling the users information.

Below is the code to get the graphClient instance and then subsequently fetching the users information. It is observed that one instance of app is returning the data (which is currently pulling delta users), however, the other instance of app is not fetching any data even without delta link (Full snapshot).


ClientSecretCredential credential = new ClientSecretCredentialBuilder()
        .clientId(clientId)
        .clientSecret(clientSecret)
        .tenantId(tenantId)
        .authorityHost(authorityHost)
        .build();



GraphServiceClient graphServiceClient = new GraphServiceClient(credential, "https://graph.microsoft.com/.default");

graphClient.getRequestAdapter().setBaseUrl("https://graph.microsoft.com/v1.0");


// To get all users information -> Full Snapshot
DeltaGetResponse userResponse = graphClient.users().delta().get(requestConfiguration -> {
                requestConfiguration.headers.add("Prefer", "return=minimal");
                requestConfiguration.queryParameters.top = 500;
            });

// Delta pull for the users
DeltaRequestBuilder builder = new DeltaRequestBuilder(userResponse.getOdataNextLink(), graphClient.getRequestAdapter());
	userResponse = builder.get(requestConfiguration -> {
                    requestConfiguration.queryParameters.top = 500;
                });



Any help will be greatly appreciated.

Thank you!

Microsoft Security | Microsoft Entra | Microsoft Entra ID

Answer accepted by question author

  1. Sridevi Machavarapu 29,630 Reputation points Microsoft External Staff Moderator
    2026-04-22T22:05:09.07+00:00

    Hello Kumar Sugandh,

    This looks like a delta token issue rather than a GraphClient problem.

    For /users/delta, the expected flow is:

    1. Call GET /users/delta
    2. Follow all @odata.nextLink pages
    3. Continue until you receive @odata.deltaLink
    4. Save only the final @odata.deltaLink for the next sync

    If both app instances are running at the same time and using the same stored delta token, one instance may update it while the other is still using the older value. This can cause one instance to return data while the other gets empty results, even during what looks like a full sync.

    Also, for the first full sync, avoid using:

    Prefer: return=minimal
    

    This is mainly useful when using an existing @odata.deltaLink, not for the initial full snapshot.

    Please check:

    • only one instance should manage delta sync, or each instance should keep its own delta token
    • save only @odata.deltaLink, not @odata.nextLink
    • confirm User.Read.All and Directory.Read.All Application permissions are granted with admin consent

    A common setup is to let one instance handle the sync and store the results in DB, while the second instance reads from the DB instead of calling Graph directly.

    Most likely, both instances sharing the same delta state is causing the issue.

    Was this answer helpful?

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.