microsoftgraph / microsoftgraph/msgraph-sdk-java

Can not make request after migrating to V6 from V5

Đang mở
#2,236 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Needs: Attention :wave: type:question
Ngôn ngữ chính
Java
Star
444
Fork
154
Merge trung bình
18 giờ 28 phút
Pull request đã merge (30 ngày)
4

Mô tả

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();
    }

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với lệnh gọi users.get() đã được báo cáo và các điểm đầu vào của stack trace trong AzureIdentityAccessTokenProvider và OkHttpRequestAdapter. Kiểm tra các phiên bản dependency Azure Core và Microsoft Graph/Kiota đã được resolve liên quan đến TokenRequestContext.setCaeEnabled(boolean), sau đó tái hiện request bằng GraphConfiguration được cung cấp. Công việc hoàn tất khi client đã migrate có thể thực hiện request Azure B2C mà không gặp NoSuchMethodError đã được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
azure, java
Lĩnh vực
api, authentication, backend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
32/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.