microsoftgraph / microsoftgraph/msgraph-sdk-java

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

未关闭
#2,294 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

status:waiting-for-triage type:bug
主要语言
Java
星标
444
派生
154
平均合并
18 小时 28 分钟
30 天内合并 PR
4

描述

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_

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 GraphServicesClient 构造函数开始,跟踪其 scopes 如何传递到 AzureIdentityAccessTokenProvider 以及 stack trace 中显示的 Azure identity credential。使用两个 scopes 重现该客户端,然后验证使用它不再引发 ScopeUtil resource-string 错误,并确认单个 scope 的行为保持不变。

由索引模型根据 Issue 内容生成。

评估

技术栈
azure, java
领域
api, authentication
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。