microsoftgraph / microsoftgraph/msgraph-sdk-java

Can not make request after migrating to V6 from V5

Open
#2,236 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs: Attention :wave: type:question
Dominant language
Java
Stars
444
Forks
154
Avg merge
18h 28m
Merged PRs (30d)
4

Description

I followed the migration instruction here. After the migration to V6.21, I can not make any request to Azure B2C.
This is the error I am getting:

java.lang.NoSuchMethodError: 'com.azure.core.credential.TokenRequestContext com.azure.core.credential.TokenRequestContext.setCaeEnabled(boolean)'
at com.microsoft.kiota.authentication.AzureIdentityAccessTokenProvider.getAuthorizationToken(AzureIdentityAccessTokenProvider.java:161) ~[microsoft-kiota-authentication-azure-1.7.0.jar:na]
at com.microsoft.kiota.authentication.BaseBearerTokenAuthenticationProvider.authenticateRequest(BaseBearerTokenAuthenticationProvider.java:46) ~[microsoft-kiota-abstractions-1.7.0.jar:na]
at com.microsoft.kiota.http.OkHttpRequestAdapter.getHttpResponseMessage(OkHttpRequestAdapter.java:710) ~[microsoft-kiota-http-okHttp-1.7.0.jar:na]
at com.microsoft.kiota.http.OkHttpRequestAdapter.send(OkHttpRequestAdapter.java:275) ~[microsoft-kiota-http-okHttp-1.7.0.jar:na]
at com.microsoft.graph.users.item.UserItemRequestBuilder.get(UserItemRequestBuilder.java:761) ~[microsoft-graph-6.20.0.jar:na]
at com.microsoft.graph.users.item.UserItemRequestBuilder.get(UserItemRequestBuilder.java:747) ~[microsoft-graph-6.20.0.jar:na]

I also try the latest kiota version 1.8.x but it did not help.
What am I missing here?

Here are the changes regarding the authentication:

@Configuration
public class GraphConfiguration {
    private static final String SCOPE = "https://graph.microsoft.com/.default";

    @Bean
    public GraphServiceClient graphClient(AadAuthenticationProperties aadAuthenticationProperties) throws Exception {
        ClientSecretCredential credential = new ClientSecretCredentialBuilder()
                .clientId(aadAuthenticationProperties.getCredential().getClientId())
                .clientSecret(aadAuthenticationProperties.getCredential().getClientSecret())
                .tenantId(aadAuthenticationProperties.getProfile().getTenantId())
                .build();

        if (null == scopes || null == credential) {
            throw new Exception("Unexpected error while initializing GraphServiceClient");
        }

        return new GraphServiceClient(credential, SCOPE);
    }
}

And the call looks like this:

public void getLoggedInUserInfo() {
        var users = graphServiceClient
                .users
                .get();
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported users.get() call and the stack-trace entry points in AzureIdentityAccessTokenProvider and OkHttpRequestAdapter. Inspect the resolved Azure Core and Microsoft Graph/Kiota dependency versions around TokenRequestContext.setCaeEnabled(boolean), then reproduce the request with the shown GraphConfiguration. Done when the migrated client can make the Azure B2C request without the reported NoSuchMethodError.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, java
Domain
api, authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.