Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassCastException: java.util.Collections$SingletonList cannot be cast to java.lang.String #85

Closed
eparkhomenko opened this issue Oct 4, 2019 · 5 comments

Comments

@eparkhomenko
Copy link

When I try to get application credentials using following code:
PartnerCredentials.getInstance().generateByApplicationCredentials(
account.getCspClientId(),
account.getCspKey(),
"/" + account.getCspDomain() // e.g. 'test.onmicrosoft.com'
);

I see such exception:

com.microsoft.store.partnercenter.exception.PartnerException: Failed to do the application AAD login at com.microsoft.store.partnercenter.extensions.ApplicationPartnerCredentials.authenticate(ApplicationPartnerCredentials.java:172) ~[partnercenter-1.14.1.jar:1.14.1] at com.microsoft.store.partnercenter.extensions.PartnerCredentials.generateByApplicationCredentials(PartnerCredentials.java:69) ~[partnercenter-1.14.1.jar:1.14.1] at com.microsoft.store.partnercenter.extensions.PartnerCredentials.generateByApplicationCredentials(PartnerCredentials.java:50) ~[partnercenter-1.14.1.jar:1.14.1] Caused by: java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.util.Collections$SingletonList cannot be cast to java.lang.String at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357) ~[na:1.8.0_181] at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895) ~[na:1.8.0_181] at com.microsoft.store.partnercenter.extensions.ApplicationPartnerCredentials.authenticate(ApplicationPartnerCredentials.java:168) ~[partnercenter-1.14.1.jar:1.14.1] ... 103 common frames omitted Caused by: java.lang.ClassCastException: java.util.Collections$SingletonList cannot be cast to java.lang.String at com.nimbusds.oauth2.sdk.util.URLUtils.serializeParameters(URLUtils.java:105) ~[oauth2-oidc-sdk-5.18.1.jar:5.18.1] at com.microsoft.aad.msal4j.TokenRequest.toOauthHttpRequest(TokenRequest.java:168) ~[msal4j-0.5.0-preview.jar:0.5.0-preview] at com.microsoft.aad.msal4j.TokenRequest.executeOauthRequestAndProcessResponse(TokenRequest.java:55) ~[msal4j-0.5.0-preview.jar:0.5.0-preview] at com.microsoft.aad.msal4j.ClientApplicationBase.acquireTokenCommon(ClientApplicationBase.java:163) ~[msal4j-0.5.0-preview.jar:0.5.0-preview] at com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier.execute(AcquireTokenByAuthorizationGrantSupplier.java:52) ~[msal4j-0.5.0-preview.jar:0.5.0-preview] at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:57) ~[msal4j-0.5.0-preview.jar:0.5.0-preview] at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:17) ~[msal4j-0.5.0-preview.jar:0.5.0-preview]

Environment

MacOS Mojave 10.14.6 (18G95)
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

@ghost
Copy link

ghost commented Oct 10, 2019

@eparkhomenko thank you for bring this to our attention. I have recently made some changes that will address this issue.

@sean-m-oleary
Copy link

@eparkhomenko thank you for bring this to our attention. I have recently made some changes that will address this issue.

what were the changes? I'm facing a similar issue using MSAL and OAuth

@ghost
Copy link

ghost commented Nov 12, 2019

@eparkhomenko and @lanman2000 version 1.15.1 was just pushed to Maven Central, and it contains a fix for this issue. Please let us know if you have any issues are updating.

@ghost ghost closed this as completed Nov 12, 2019
@sean-m-oleary
Copy link

Thank you! @IsaiahWilliams

@abitgcp
Copy link

abitgcp commented Feb 24, 2023

Hi, Can anyone guide me what exactly was the change added in 1.15.1 version to fix this issue?
I see a lot of changes in that version and so not able to figure out what exactly was the fix.
I am facing the same issue in Partner-Center-Java-Samples Github project.
https://github.com/microsoft/Partner-Center-Java-Samples

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants