microsoftgraph / microsoftgraph/msgraph-sdk-java
Adding more than 1 scope to GraphServicesClient causes an error when using the client
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 444
- Forks
- 154
- Avg merge
- 18h 28m
- Merged PRs (30d)
- 4
Description
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_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the GraphServicesClient constructor and follow how its scopes reach AzureIdentityAccessTokenProvider and the Azure identity credential shown in the stack trace. Reproduce the client with two scopes, then verify that using it no longer raises the ScopeUtil resource-string error and that the single-scope behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, java
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100