Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not make request after migrating to V6 from V5 #2236

Open
talalong opened this issue Nov 26, 2024 · 1 comment
Open

Can not make request after migrating to V6 from V5 #2236

talalong opened this issue Nov 26, 2024 · 1 comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned

Comments

@talalong
Copy link

talalong commented Nov 26, 2024

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();
    }
@talalong talalong added the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Nov 26, 2024
@talalong
Copy link
Author

I think that's a bug because I switched to V6.13 and the error was gone. Please confirm this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned
Projects
None yet
Development

No branches or pull requests

1 participant