InteractiveBrowserCredentialBuilder : Unable to open default system browser

Srini Babu Maroju 26 Reputation points
2021-03-11T20:18:50.32+00:00

Hello,

This is about azure active directory authentication, connect to storage container using spring boot application.

I am running spring boot application in my local machine. The port is 8080. When user types url(http://localhost:8080/DisplayPDF) in browser, it needs to pop up authentication screen and after successfully authentication screen, it should render a file in Storage container.

My Code is is

InteractiveBrowserCredential interactiveBrowserCredential = new InteractiveBrowserCredentialBuilder()
.clientId(clientID)
.tenantId(tenantID)
.build();

    BlobServiceClient storageClient = new BlobServiceClientBuilder().endpoint(endpoint)
                                                    .credential(interactiveBrowserCredential)
                                        .buildClient();

I am getting error as below. Can you please advise ?

com.microsoft.aad.msal4j.MsalClientException: Unable to open default system browser
at com.microsoft.aad.msal4j.AcquireTokenByInteractiveFlowSupplier.openDefaultSystemBrowser(AcquireTokenByInteractiveFlowSupplier.java:116) ~[msal4j-1.8.0.jar:1.8.0]
at com.microsoft.aad.msal4j.AcquireTokenByInteractiveFlowSupplier.getAuthorizationResult(AcquireTokenByInteractiveFlowSupplier.java:61) ~[msal4j-1.8.0.jar:1.8.0]
at com.microsoft.aad.msal4j.AcquireTokenByInteractiveFlowSupplier.execute(AcquireTokenByInteractiveFlowSupplier.java:37) ~[msal4j-1.8.0.jar:1.8.0]
at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:59) ~[msal4j-1.8.0.jar:1.8.0]
at com.microsoft.aad.msal4j.AuthenticationResultSupplier.get(AuthenticationResultSupplier.java:17) ~[msal4j-1.8.0.jar:1.8.0]
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1764) ~[na:na]
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1756) ~[na:na]
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) ~[na:na]
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016) ~[na:na]
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665) ~[na:na]
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598) ~[na:na]
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177) ~[na:na]

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,465 questions
{count} vote

1 answer

Sort by: Most helpful
  1. JamesTran-MSFT 36,371 Reputation points Microsoft Employee
    2021-03-18T21:21:22.6+00:00

    @Srini Babu Maroju
    Thank you for your post and I apologize for the delayed response!

    For your error message, it looks like there's an issue opening your default browser? Have you had the chance to look through our MSAL.NET - How to use the Default OS Browser documentation?

    MSAL.NET needs to listen on http://localhost:port and intercept the code that AAD sends when the user is done authenticating (See Authorization code for details)To enable the system browser:

    During app registration, configure http://localhost as a redirect uri (not currently supported by B2C)
    When you construct your PublicClientApplication, specify this redirect uri:

    IPublicClientApplication pca = PublicClientApplicationBuilder  
                                .Create("<CLIENT_ID>")  
                                 // or use a known port if you wish "http://localhost:1234"  
                                .WithRedirectUri("http://localhost")    
                                .Build();  
    

    If you configure http://localhost, internally MSAL.NET will find a random open port and use it.

    If you have any other questions, please let me know.
    Thank you for your time and patience throughout this issue.

    ----------

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    0 comments No comments