The AuthenticationResultSupplier.get method fails on Linux with attached exception. The bug is the call to Runtime.exec at line 185 of AuthenticationResultSupplier. The call is passed an invalid command to execute. The command is passed without a space separating the command from the command arguments. "xdg-openhttps://login.microsoftonline.com should be "xdg-open https://login.microsoftonline.com.
runtime.exec(openTool + url);
should be changed to
runtime.exec(openTool + " " + url);
Stack Trace -
java.util.concurrent.CompletionException: java.lang.RuntimeException: java.io.IOException: Cannot run program "xdg-openhttps://login.microsoftonline.com/XXX/oauth2/v2.0/authorize?scope=openid+profile+offline_access+api%3A%2F%2F4XXX&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A42459&code_challenge_method=S256&state=XXX&code_challenge=XXX&client_id=XXX&response_mode=form_post": error=2, No such file or directory
at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:99)
at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:18)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1768)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760)
at java.base/java.util.concurrent.ForkJoinTask.doExec$$$capture(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
Caused by: java.lang.RuntimeException: java.io.IOException: Cannot run program "xdg-openhttps://login.microsoftonline.com/XXX/oauth2/v2.0/authorize?scope=openid+profile+offline_access+api%3A%2F%2F4XXX&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A42459&code_challenge_method=S256&state=XXX&code_challenge=XXX&client_id=XXXX&response_mode=form_post": error=2, No such file or directory
at com.microsoft.aad.msal4j.AcquireTokenByInteractiveFlowSupplier.openDefaultSystemBrowserInLinux(AcquireTokenByInteractiveFlowSupplier.java:187)
at com.microsoft.aad.msal4j.AcquireTokenByInteractiveFlowSupplier.openDefaultSystemBrowser(AcquireTokenByInteractiveFlowSupplier.java:143)
at com.microsoft.aad.msal4j.AcquireTokenByInteractiveFlowSupplier.getAuthorizationResult(AcquireTokenByInteractiveFlowSupplier.java:70)
at com.microsoft.aad.msal4j.AcquireTokenByInteractiveFlowSupplier.execute(AcquireTokenByInteractiveFlowSupplier.java:46)
at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:69)
... 10 more
Caused by: java.io.IOException: Cannot run program "xdg-openhttps://login.microsoftonline.com/XXX/oauth2/v2.0/authorize?scope=openid+profile+offline_access+api%3A%2F%2F4XXX&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A42459&code_challenge_method=S256&state=XXX&code_challenge=XXX&client_id=XXX&response_mode=form_post": error=2, No such file or directory
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
at java.base/java.lang.Runtime.exec(Runtime.java:594)
at java.base/java.lang.Runtime.exec(Runtime.java:418)
at java.base/java.lang.Runtime.exec(Runtime.java:315)
at com.microsoft.aad.msal4j.AcquireTokenByInteractiveFlowSupplier.openDefaultSystemBrowserInLinux(AcquireTokenByInteractiveFlowSupplier.java:185)
... 14 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
... 19 more
The AuthenticationResultSupplier.get method fails on Linux with attached exception. The bug is the call to Runtime.exec at line 185 of AuthenticationResultSupplier. The call is passed an invalid command to execute. The command is passed without a space separating the command from the command arguments.
"xdg-openhttps://login.microsoftonline.com
should be"xdg-open https://login.microsoftonline.com
.should be changed to
Stack Trace -
See code at - https://github.com/AzureAD/microsoft-authentication-library-for-java/blame/8bf42f2efa3bf9d70f036ac946347f8950c6b487/msal4j-sdk/src/main/java/com/microsoft/aad/msal4j/AcquireTokenByInteractiveFlowSupplier.java#L185