question

SriniBabuMaroju-8087 avatar image
0 Votes"
SriniBabuMaroju-8087 asked azure-cxp-api edited

InteractiveBrowserCredentialBuilder : Unable to open default system browser

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]

azure-active-directoryazure-ad-msal
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

To add to my questions, my configuration settings(at app registration) are as below

API permission


I have given following permissions
Storage - User_impression
graph - User.read


Authentication


Platform configuration
Web and desktop applications--> Redirect URI localhost:80080

Advanced settings
Allow public client flows -> Yes

Manifest


allowPublicClient -> true

Hope this gives more clarity

0 Votes 0 ·

1 Answer

JamesTran-MSFT avatar image
0 Votes"
JamesTran-MSFT answered

@SriniBabuMaroju-8087
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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.