Azure-Samples / ms-identity-java-desktop

A desktop application in Java calling Microsoft Graph API
MIT License
23 stars 23 forks source link

Token not found in the cache #14

Closed satishbolisetty closed 3 years ago

satishbolisetty commented 3 years ago

Hello Team,

We are facing issue when executing the "UsernamePasswordFlow.java". We have provided required information Client_Id.Username and password. We are getting error on line number 80 when getting token.

Kindly let us the know the insights of the issue.

Stack Trace: ==acquireTokenSilently call failed: com.microsoft.aad.msal4j.MsalClientException: Token not found in the cache [ForkJoinPool.commonPool-worker-2] ERROR com.microsoft.aad.msal4j.PublicClientApplication - [Correlation ID: 467137f6-c2b5-465c-b065-5db00ea99b88] Execution of class com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier failed. com.microsoft.aad.msal4j.MsalServiceException: AADSTS50059: No tenant-identifying information found in either the request or implied by any provided credentials. Trace ID: 9d3e9b2b-4d45-49c1-b65b-18c7c9177b00 Correlation ID: 467137f6-c2b5-465c-b065-5db00ea99b88 Timestamp: 2020-12-09 20:20:46Z at com.microsoft.aad.msal4j.MsalServiceExceptionFactory.fromHttpResponse(MsalServiceExceptionFactory.java:43) at com.microsoft.aad.msal4j.TokenRequestExecutor.createAuthenticationResultFromOauthHttpResponse(TokenRequestExecutor.java:85) at com.microsoft.aad.msal4j.TokenRequestExecutor.executeTokenRequest(TokenRequestExecutor.java:36) at com.microsoft.aad.msal4j.AbstractClientApplicationBase.acquireTokenCommon(AbstractClientApplicationBase.java:105) at com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier.execute(AcquireTokenByAuthorizationGrantSupplier.java:63) at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:59) at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:17) at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604) at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)

Thanks

Avery-Dunn commented 3 years ago

Hello @satishbolisetty : It looks like the real issue is the part of the stack trace that says "AADSTS50059: No tenant-identifying information...", and the 'token not found in the cache' is an expected error for the first silent call in this sample (since the token cache is empty).

I haven't been able to recreate your issue, but since the it seems tenant related it could be either a problem with the authority URL or an issue with the app in Azure. I believe some accounts need a tenant-specific authority to work, so in the authorities field of application.properties, try replacing 'organizations' in the authority URL with the tenant the app is in (i.e., it should be AUTHORITY=https://login.microsoftonline.com/{your tenant ID}/). Other than that, double-check to sure that the app is set up according to the README (it supports accounts in any organizational directory, the allowPublicClient field in the manifest is true, consent was granted, etc.)

Avery-Dunn commented 3 years ago

Closing due to inactivity. If you're still experiencing this issue or any related issues, feel free to reopen this thread or leave a comment.