question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Source Link on Bitbucket Cloud fails to authenticate MFA with VS2017

See original GitHub issue

Hi, I’ve run into troubles using Source Link on a Bitbucket Cloud multifactor auth account on VS2017 Enterprise 15.9.7.

Git Credential Manager setup This is output for the system version, though Visual Studio uses its’ own. As the installer doesn’t automatically detect this, I’ve manually copied git-askpass.exe, git-credential-manager.exe and *.dll (including the one for Bitbucket) so that VS picks this version up. Filepath: ..\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core

Logs below pick up the right version when trying to authenticate with Source Link so I’m assuming that GCM has installed ok.

git credential-manager version
Git Credential Manager for Windows version 1.18.4

Expected behavior In Visual Studio/Source link, we expect the ‘Source link authentication failed’ window to close after authentication with a new one detailing the source file I’m attempting to view in Bitbucket. In git.log, lines after: 20:46:45.000007 ...\Common.cs:744 trace: [Main] git-credential-manager (v1.18.4) 'reject' which deletes credentials shouldn’t happen.

Actual behavior Stepping through debugger with Source link gives me an Authentication failure when trying to a view a file on Bitbucket: here Clicking the link to authenticate brings up the Atlassian UI to login, followed by another popup with a single button to Authorise MFA access. Clicking this opens a confirmation page in browser for Source Tree with token: here However, nothing else happens from here (in VS or otherwise) - Authentication failed window stays, and clicking the link again just restarts the process. The log seems to go wrong after: 20:46:41.337751 ...\Common.cs:709 trace: [LogEvent] Bitbucket credentials for 'https://bitbucket.org/' successfully retrieved.

My debug VS options are here: here

I started the process up to my first screenshot with Auth failure window and cleared the log first, so this trace should reflect what happens during the auth process.

20:46:04.927318 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.18.4) 'get'
20:46:04.988317 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
20:46:04.994318 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 25 entries.
20:46:04.998318 ...\Common.cs:479       trace: [LoadOperationArguments] interactive = 'true'.
20:46:05.050317 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'https://bitbucket.org/'.
20:46:05.063317 ...uthentication.cs:313 trace: [GetAuthentication] authentication for Bitbucket created
20:46:05.063317 ...\Common.cs:192       trace: [CreateAuthentication] authority for 'https://bitbucket.org/'  is Bitbucket.
20:46:05.063317 ...\Common.cs:765       trace: [QueryCredentials] querying 'Bitbucket' for credentials.
20:46:05.103316 ...icationPrompts.cs:96 trace: [CredentialModalPrompt] prompting user for credentials.
20:46:33.426772 ...\RestClient.cs:35    trace: [TryGetUser] server responded with Forbidden.
20:46:33.426772 ...\RestClient.cs:55    trace: [TryGetUser] two-factor app authentication code required
20:46:33.427772 ...hAuthenticator.cs:38 trace: [GetAuthAsync] authentication failed
20:46:33.428770 ...cationPrompts.cs:121 trace: [AuthenticationOAuthModalPrompt] prompting user for authentication code.
20:46:37.740215 ...Authenticator.cs:182 trace: [GetAccessToken] server responded with OK.
20:46:37.748189 ...Authenticator.cs:355 trace: [GetAuthenticationResult] authentication success: new personal access token created.
20:46:38.764789 ...\RestClient.cs:35    trace: [TryGetUser] server responded with OK.
20:46:38.764789 ...\RestClient.cs:42    trace: [TryGetUser] authentication success: new password token created.
20:46:38.765777 ...\RestClient.cs:80    trace: [FindUsername] Found username [xxxxxxxxx]
20:46:38.765777 ...\Authority.cs:104    trace: [AcquireToken] Remote username [xxxxxxxxx] != [xxxxxxxxxxx@xxxxxxxx] supplied username
20:46:38.765777 ...uthentication.cs:370 trace: [InteractiveLogon] token acquisition succeeded
20:46:38.767775 ...uthentication.cs:251 trace: [SetCredentials] xxxxxxxxx at https://bitbucket.org/
20:46:38.768773 ...uthentication.cs:251 trace: [SetCredentials] xxxxxxxxx at https://xxxxxxxxx@bitbucket.org/
20:46:38.784776 ...uthentication.cs:251 trace: [SetCredentials] BitbucketRefresh at https://bitbucket.org/refresh_token
20:46:38.784776 ...uthentication.cs:251 trace: [SetCredentials] BitbucketRefresh at https://BitbucketRefresh@bitbucket.org/refresh_token
20:46:38.802775 ...\Authority.cs:214    trace: [ValidateCredentials] authentication type = 'Credential'.
20:46:40.275672 ...\RestClient.cs:35    trace: [TryGetUser] server responded with Unauthorized.
20:46:40.275672 ...\RestClient.cs:61    trace: [TryGetUser] authentication unauthorized
20:46:40.275672 ...\Authority.cs:225    trace: [ValidateCredentials] credential validation failed
20:46:40.275672 ...\Authority.cs:214    trace: [ValidateCredentials] authentication type = 'Token'.
20:46:41.336747 ...\RestClient.cs:35    trace: [TryGetUser] server responded with OK.
20:46:41.336747 ...\RestClient.cs:42    trace: [TryGetUser] authentication success: new password token created.
20:46:41.336747 ...\RestClient.cs:80    trace: [FindUsername] Found username [xxxxxxxx]
20:46:41.336747 ...\Authority.cs:221    trace: [ValidateCredentials] credential validation succeeded
20:46:41.336747 ...\Common.cs:897       trace: [QueryCredentials] credentials for 'https://bitbucket.org/' found.
20:46:41.337751 ...\Common.cs:709       trace: [LogEvent] Bitbucket credentials for 'https://bitbucket.org/' successfully retrieved.
20:46:45.000007 ...\Common.cs:744       trace: [Main] git-credential-manager (v1.18.4) 'reject'
20:46:45.060006 ...\Git\Where.cs:348    trace: [FindGitInstallations] found 1 Git installation(s).
20:46:45.065005 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 25 entries.
20:46:45.097033 ...\Common.cs:85        trace: [CreateAuthentication] detecting authority type for 'https://bitbucket.org/'.
20:46:45.111007 ...uthentication.cs:313 trace: [GetAuthentication] authentication for Bitbucket created
20:46:45.111007 ...\Common.cs:192       trace: [CreateAuthentication] authority for 'https://bitbucket.org/'  is Bitbucket.
20:46:45.111007 ...\Common.cs:273       trace: [DeleteCredentials] deleting Bitbucket credentials for 'https://bitbucket.org/'.
20:46:45.114008 ...Authentication.cs:99 trace: [DeleteCredentials] Deleting Bitbucket Credentials for https://bitbucket.org/
20:46:45.125007 ...aseSecureStore.cs:68 trace: [Delete] credentials for 'git:https://bitbucket.org' deleted from store.
20:46:45.126008 ...uthentication.cs:106 trace: [DeleteCredentials] host credentials deleted for https://bitbucket.org/
20:46:45.131016 ...aseSecureStore.cs:68 trace: [Delete] credentials for 'git:https://bitbucket.org/refresh_token' deleted from store.
20:46:45.131016 ...uthentication.cs:115 trace: [DeleteCredentials] host refresh credentials deleted for https://bitbucket.org/refresh_token

Any guidance on how to proceed from here would be greatly appreciated - thanks in advance!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
JonCubedcommented, Oct 21, 2019

@chuckries @tmat I noticed that #447 got merged any chance we can get it pushed to nightly or nuget.org to take it for a run?

1reaction
JonCubedcommented, Oct 21, 2019

@chuckries @tmat is there any update on your investigation of this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to login to bitbucket using MFA
The reason I ask is that some users may have enabled 2FA for the Atlassian account and 2SV on their Bitbucket account. These...
Read more >
Unable to use SourceLink on Bitbucket with 2FA
Visual Studio debugger is unable to access private Bitbucket repository with 2FA. Seems that support for this was added in SourceLink -
Read more >
atlassian sourcetree - Authentication failed to bitbucket
I recently had a similar issue with SourceTree: any time I tried to push/pull/fetch to/from the remote origin I would get an authentication...
Read more >
Create a Bitbucket App Password example
Learn how to quickly create a Bitbucket App Password so your Git push and ... fail with fatal 'invalid credentials for authentication' errors....
Read more >
Code Reviews Using the Visual Studio Pull Requests ...
The Pull Requests for Visual Studio is a new experimental extension that adds several code review tools to Visual Studio.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found