Skip to content

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

@aappddeevv

Description

@aappddeevv

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_

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:waiting-for-triageAn issue that is yet to be reviewed or assignedtype:bugA broken experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions