microsoft / azure-devops-intellij

IntelliJ IDEA plug-in for Visual Studio Team Services and Team Foundation Server (TFS)
MIT License
151 stars 94 forks source link

Unable to authenticate #391

Open FireFly26 opened 4 years ago

FireFly26 commented 4 years ago

I'm unable to authenticate to Azure DevOps from Rider with the following exception:

getAuthenticationInfoAsync failed

com.microsoft.alm.client.model.VssServiceResponseException: Bad Request at com.microsoft.alm.client.AlmHttpClientBase.handleResponse(AlmHttpClientBase.java:559) at com.microsoft.alm.client.AlmHttpClientBase.sendRequest(AlmHttpClientBase.java:508) at com.microsoft.alm.client.AlmHttpClientBase.sendRequest(AlmHttpClientBase.java:518) at com.microsoft.visualstudio.services.account.AccountHttpClient.getMyProfile(AccountHttpClient.java:55) at com.microsoft.alm.plugin.authentication.facades.VsoAuthInfoProvider.getAuthenticationInfo(VsoAuthInfoProvider.java:123) at com.microsoft.alm.plugin.authentication.facades.VsoAuthInfoProvider.getAuthenticationInfoAsync(VsoAuthInfoProvider.java:95) at com.microsoft.alm.plugin.authentication.VsoAuthenticationProvider.authenticateAsync(VsoAuthenticationProvider.java:66) at com.microsoft.alm.plugin.idea.common.ui.common.LookupHelper.authenticateAndLoadVsoContexts(LookupHelper.java:158) at com.microsoft.alm.plugin.idea.common.ui.checkout.VsoCheckoutPageModel.loadRepositories(VsoCheckoutPageModel.java:79) at com.microsoft.alm.plugin.idea.common.ui.checkout.CheckoutPageController.actionPerformed(CheckoutPageController.java:92) at com.microsoft.alm.plugin.idea.common.ui.controls.Hyperlink.notifyActionListeners(Hyperlink.java:91) at com.microsoft.alm.plugin.idea.common.ui.controls.Hyperlink.access$000(Hyperlink.java:25) at com.microsoft.alm.plugin.idea.common.ui.controls.Hyperlink$1.linkSelected(Hyperlink.java:35) at com.intellij.ui.components.labels.LinkLabel.doClick(LinkLabel.java:138) at com.intellij.ui.components.labels.LinkLabel.doClick(LinkLabel.java:348) at com.intellij.ui.components.labels.LinkLabel$MyMouseHandler.mouseReleased(LinkLabel.java:322) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6650) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345) at java.desktop/java.awt.Component.processEvent(Component.java:6415) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5025) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4857) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4857) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:967) at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:904) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:836) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:450) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:744) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:449) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:503) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:117) at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190) at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235) at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233) at java.desktop/java.awt.Dialog.show(Dialog.java:1063) at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:710) at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:437) at com.intellij.openapi.ui.DialogWrapper.doShow(DialogWrapper.java:1702) at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1661) at com.intellij.openapi.ui.DialogWrapper.showAndGet(DialogWrapper.java:1675) at com.microsoft.alm.plugin.idea.common.ui.common.BaseDialogImpl.showModalDialog(BaseDialogImpl.java:192) at com.microsoft.alm.plugin.idea.common.ui.checkout.CheckoutController.showModalDialog(CheckoutController.java:75) at com.microsoft.alm.plugin.idea.git.extensions.GitCheckoutProvider.doCheckout(GitCheckoutProvider.java:39) at com.intellij.openapi.vcs.ui.VcsCloneComponentStub.doClone(VcsCloneComponentStub.kt:32) at com.intellij.util.ui.cloneDialog.RepositoryUrlCloneDialogExtension$RepositoryUrlMainExtensionComponent.doClone(RepositoryUrlCloneDialogExtension.kt:106) at com.intellij.util.ui.cloneDialog.VcsCloneDialog.doClone(VcsCloneDialog.kt:86) at com.intellij.openapi.wm.impl.welcomeScreen.GetFromVersionControlAction.actionPerformed(GetFromVersionControlAction.kt:44) at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:282) at com.intellij.openapi.actionSystem.ex.ActionUtil.invokeAction(ActionUtil.java:446) at com.intellij.openapi.actionSystem.ex.ActionUtil.invokeAction(ActionUtil.java:431) at com.intellij.ui.components.labels.ActionLink$1.linkSelected(ActionLink.java:47) at com.intellij.ui.components.labels.LinkLabel.doClick(LinkLabel.java:138) at com.intellij.ui.components.labels.ActionLink.doClick(ActionLink.java:56) at com.intellij.ui.components.labels.LinkLabel$MyMouseHandler.mouseReleased(LinkLabel.java:322) at java.desktop/java.awt.Component.processMouseEvent(Component.java:6650) at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345) at java.desktop/java.awt.Component.processEvent(Component.java:6415) at java.desktop/java.awt.Container.processEvent(Container.java:2263) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5025) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4857) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4857) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751) at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:967) at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:904) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:836) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:450) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:744) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:449) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:503) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

ForNeVeR commented 4 years ago

Please provide details: what were you trying to do, what kind of TFVC server do you use, and add IDE logs.

FireFly26 commented 4 years ago

I'm trying to clone a git repo from azure devops. When I do this Rider presents the screen in attachment, I click Sign in.... , enter my username and pwd (of which I'm sure they are correct) and then the sign in fails with above exception and error message as seen in the screenshot.

I added the rider logs also.

rider_log.zip

rider_screenshot

ForNeVeR commented 4 years ago

Well, it's possible that "Bad request" is really all that the server tells us. I've already seen a problem like this from the user who had too many organizations associated with their access token.

To verify this, please tell, how fluent are you with Java? The easiest solution would be to run the plugin with debugger and check the length of tokenPair.AccessToken.Value at this line.

If you aren't so fluent with Java, you could add a line to write this information into the IDE log (and build the plugin yourself):

logger.info("!! Access Token Length: " + tokenPair.AccessToken.Value.length());

For instance, my token length is 1548 characters. I vaguely remember that they have a restriction for about 10 or 15 KiB (but Azure never confirmed this to us).

I could also build the plugin for you, but that'll require a bit more work (since I'll have to share the binary build with you). Still doable if necessary.

If this length is too big, we'll add some warnings to the plugin code, and you'll eventually have to contact Azure support for this case, unfortunately.

(Or maybe we could somehow restrict scope of our tokens beforehand? I'll have to check.)

FireFly26 commented 4 years ago

@ForNeVeR I'm a .net developer :) I did some java back in school but I think thigs have changed since then. So I think I will need some assistance here.

ForNeVeR commented 4 years ago

Understood. I am a .NET developer myself :)

I've built a plugin binary with additional diagnostics, please download it here, and then install (in the IDE plugin settings, click the gear icon and select Install Plugin from Disk).

After that, restart the IDE, try to authenticate again, and then open IDE log file (Help → Diagnostic Tools → Show Log in Explorer). Look for line !! Access Token Length in the log, and report the value that it tells you.

Hopefully this will help us to determine what's going on here.

FireFly26 commented 4 years ago

@ForNeVeR I installed the version and in the log I see !! Access Token Length: 11342

Does this help?

luedi commented 4 years ago

I have a similar problem, but i think i know the reason for it. When i try to connect to my Azure Devops account while working in my company's network (connected via VPN) the Sign In window went into an infinite loop when i click "Sign In". When i disable the VPN i can connect without any trouble. My Company's firewall break up ssl connections to inspect the traffic for viruses and malware. So i think there is a certifcate problem as, when i'm right, special certifcates are used to be able to break up ssl connections.

ForNeVeR commented 4 years ago

@luedi, for your case (which has no connection to the current one), the workaround would be to add your server certificate to cacerts of JetBrains Java runtime distribution. Check this Stack Overflow answer on how to do it.

ForNeVeR commented 4 years ago

@FireFly26, and regarding your answer: thanks for help, it is all I need to know currently. I'll take a look on what are our options for this case. For now, could you try enabling Device Flow authentication? image

FireFly26 commented 4 years ago

@ForNeVeR I tried enabling Device Flow but I get exactly the same exception as on Username and password flow.

FireFly26 commented 3 years ago

@ForNeVeR Any update on this?

AviCueva commented 3 years ago

I was able to solve this issue by:

Installing latest version of git ( Installing Credential Manager option)

From settings: Version Control -> Git - > Use Credential helper (check on)