Azure / azure-libraries-for-java

Azure Management Libraries for Java
https://docs.microsoft.com/en-us/java/azure/
MIT License
94 stars 98 forks source link

[BUG Bash] `InteractiveBrowserCredentialBuilder` uses 0 as the default port which will not work #1219

Open Flanker32 opened 4 years ago

Flanker32 commented 4 years ago

Describe the bug InteractiveBrowserCredentialBuilder uses 0 as the default port, which we can't get Azure's response.

Exception or Stack Trace

This site can’t be reachedThe webpage at http://localhost:0/?code=CODE&session_state=SESSION might be temporarily down or it may have moved permanently to a new web address.

To Reproduce Steps to reproduce the behavior: Run codes in Code Snippet

Code Snippet Add the code snippet that causes the issue.

AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
        TokenCredential credential = new InteractiveBrowserCredentialBuilder()
                .clientId("CLIENT_ID").build();
Azure azure = Azure
                .authenticate(credential, profile)
                .withSubscription("SUBSCRIPTION");
for (Subscription subscription : azure.subscriptions().list()) {
    System.out.println(subscription.displayName());
}

Expected behavior SDK use an valid port as the default value or throw exception that we must specify the port first

Setup (please complete the following information):

Additional context N/A

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

weidongxu-microsoft commented 4 years ago

@xccc-msft Please take a look on this 2 issue about InteractiveBrowser when you have time. Report to azure-identity if confirmed.

@Flanker32 Here is a bit more material on the new azure-identity from Jianghao (it might be a bit out-dated).

PPT https://microsoft.sharepoint.com/:p:/t/AzureDeveloperExperience/EbI-QvCV_V1GkTemPLYZfw4BU3g5glwtCTvPrmJ003A4Lw?e=XkYzft&wdLOR=c2E9DC7C8-18EB-4C88-808D-DA6F8F21527A

Video recording https://msit.microsoftstream.com/video/ad5be47c-346e-49ab-ba0c-c961665a5436 https://msit.microsoftstream.com/video/ce38c71b-9fe0-4353-8fa4-81450d8df954

xseeseesee commented 4 years ago

@Flanker32 It looks port 0 would trigger the scenario for system to find next available port. Most likely the actual picked port is not registered yet. I will try to register port 0 first according to guidance and investigate this issue.

In this case, I think we may suggest Azure Identity to add validation scenario for the port value.

yungezz commented 4 years ago

fro linked issue, the issue is fixed in latest azure-identity release. @Flanker32 you might want to have a try on it.