microsoftgraph / microsoftgraph/msgraph-sdk-java

Adding more than 1 scope to GraphServicesClient causes an error when using the client

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

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

status:waiting-for-triage type:bug
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ả

Describe the bug

If I true to use more than 1 scope when creating a client new GraphServicesClient(myCredential, scope1, scope2)

an error is encountered when trying to use it:

Exception in thread "main" com.azure.identity.CredentialUnavailableException: To convert to a resource string the specified array must be exactly length 1
        at com.azure.identity.AzureCliCredential.getTokenSync(AzureCliCredential.java:103)
        at com.azure.identity.ChainedTokenCredential.getTokenSync(ChainedTokenCredential.java:134)
        at com.microsoft.kiota.authentication.AzureIdentityAccessTokenProvider.getAuthorizationToken(AzureIdentityAccessTokenProvider.java:167)
        at com.microsoft.kiota.authentication.BaseBearerTokenAuthenticationProvider.authenticateRequest(BaseBearerTokenAuthenticationProvider.java:46)
        at com.microsoft.kiota.http.OkHttpRequestAdapter.getHttpResponseMessage(OkHttpRequestAdapter.java:710)
        at com.microsoft.kiota.http.OkHttpRequestAdapter.send(OkHttpRequestAdapter.java:275)
...redacted...
Caused by: java.lang.IllegalArgumentException: To convert to a resource string the specified array must be exactly length 1
        at com.azure.identity.implementation.util.ScopeUtil.scopesToResource(ScopeUtil.java:27)
        at com.azure.identity.implementation.IdentitySyncClient.authenticateWithAzureCli(IdentitySyncClient.java:375)
        at com.azure.identity.AzureCliCredential.getTokenSync(AzureCliCredential.java:97)
        ... 11 more
Expected behavior

To allow more than 1 scope.

How to reproduce

Add more than 1 scope to the constructor.

SDK Version

6.x

Latest version known to work for scenario above?

No response

Known Workarounds

None

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

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 constructor của GraphServicesClient và theo dõi cách các scope của nó đi đến AzureIdentityAccessTokenProvider và credential định danh Azure được hiển thị trong stack trace. Tái tạo client với hai scope, sau đó xác minh rằng việc sử dụng nó không còn gây ra lỗi resource-string của ScopeUtil và hành vi với một scope duy nhất vẫn được giữ nguyên.

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
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
35/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.