Azure-Samples / ms-identity-java-webapp

A Java web application calling Microsoft graph that is secured using the Microsoft identity platform
MIT License
118 stars 105 forks source link

msal-java-webapp-sample - Execution of class com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier failed. #80

Open ChakriGangaraj opened 3 years ago

ChakriGangaraj commented 3 years ago

I am trying with the sample msal-java-webapp-sample for Azure SSO. Getting redirected to Azure login page and after giving user name & password able to get successful code. Getting below exception, while trying to acquire token.

Error.txt future - java.util.concurrent.CompletableFuture@7ee7be0e[Not completed] ERROR 22084 --- [onPool-worker-1] c.m.a.m.ConfidentialClientApplication : [Correlation ID: 5aa9bff9-0fbd-4a9a-be38-8161e39023ac] Execution of class com.microsoft.aad.msal4j.AcquireTokenByAuthorizationGrantSupplier failed.

Not much changes done on the provided sample from my end except running application as http instead of https. Any help much appreciated.

sangonzal commented 3 years ago

@ChakriGangaraj From the Error.txt that you included, the actual error is: com.microsoft.aad.msal4j.MsalClientException: java.net.SocketTimeoutException: connect timed out. This is a network related issue, perhaps caused by the changes you made in trying to run it using http. It's hard to say what could be causing it. Does the sample work for you if you don't make any changes to it?

ChakriGangaraj commented 3 years ago

My network doesn't allow me to try with self signed certificate and hence running as http. Just removed ssl related properties in application.properties. If there is network issue it should stop even while logging in. But that step is successful and while acquiring token getting the issue.

ChakriGangaraj commented 3 years ago

Why its labelled as Question? I am not able to run this sample and its failing to acquire token by providing auth code.

ChakriGangaraj commented 3 years ago

Is that https environment mandatory to run the sample? I registered http redirect URLS in Azure AD app registration and trying application without https. Can any one tried this sample to run with http?

Avery-Dunn commented 3 years ago

Hello @ChakriGangaraj : Sorry for the delayed response, are you still having these issues? If so, then it's likely because more changes are needed to run everything with http. https isn't mandatory to run these samples, but most URLs assume that https will be used: in application.properties you'll need to change instances of 'https' and '8443' to 'http' and '8080', and the same for some references in AuthPageController. There might also be issues with newer versions of Spring not liking http by default, so you may run into issues there as well.