msgraph-sdk-java icon indicating copy to clipboard operation
msgraph-sdk-java copied to clipboard

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

Open aappddeevv opened this issue 1 year ago • 0 comments

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_

aappddeevv avatar Feb 08 '25 18:02 aappddeevv