SourceTree for Windows authentication issues
Asked by kevin.foley.cda:

SourceTree 2.1.2.5

Windows 10 Home 64-bit

I connect to several Git repositories on GitHub, and several Git and Mercurial repositories on Bitbucket, using SourceTree. Roughly every 10 minutes, SourceTree asks me to enter my username and password for Bitbucket, even though these are already saved in the "Accounts" list. This issue also occurred in SourceTree 1.9.x.

Approximately once every ten minutes, SourceTree displays a "Windows Security" dialog with the title "Git Credential Manager for Windows" and message "Enter your credentials for <https://bitbucket.org>". If I enter my credentials, the dialog goes away, but comes back roughly 10 minutes later.

If I go to the Accounts list (Tools \> Options \> Authentication), there are four accounts listed:

1. "bitbucket.org"  
Host: bitbucket.org  
Username: myusername  
Authentication: OAuth  
Default account for bitbucket.org: Yes

*This account has a Delete button, but nothing happens if I press it*

2. "github.com"  
Host: github.com  
Username: Personal Access Token  
Authentication: Basic  
Default account for github.com: Yes

*This account has a Delete button. If I press it, a confirmation dialog appears. If I confirm, the account is removed from the list*

3. "myusername@"  
Host:   
Username: myusername  
Authentication: Basic  
Default account for : Yes

*This account has no Host name. It does have a Delete button. If I press it, a confirmation dialog appears. If I confirm, nothing happens and the account remains in the list.*

4. "myaccount@bitbucket.org"  
Host: bitbucket.org  
Username: myusername  
Authentication: OAuth  
Default account for Bitbucket.org: No

*This account has a Delete button, but nothing happens if I press it*


Answers:
author: jasemitchell
body: I've had this issue off-and-on for the past year or so - although I'm not connecting to GitHub, just Bitbucket. I'm currently running v2.1.10.0 on Win8 although I think it was occurring in the previous release (v2.1.8.0) as well. I use SSH to connect to Bitbucket via Pageant.

The last time it started occuring I was able to fix it by going into Tools -\> Options -\> Authentication, and after clicking edit on my OAuth account I saw that my token had expired, which was fixed by clicking "Refresh OAuth Token".

I then needed to click the "Set as default" link for that account, and ensure that under the Saved Passwords section, my bitbucket.org account had "Default account for bitbucket.org : Yes".

This fix used to last for weeks or months and I could authenticate via SSH without the Git Credential Manager prompts popping up.

Recently this issue has started occurring again, and it seems that SourceTree is forgetting my OAuth token daily. Each morning when the login popups start appearing, I go into my Authentication menu and I see that my token has expired. After refreshing it, I see that it's not marked as the default account and there is no saved credential.

I also had the stupid "myusername@" credential listed in my Authentication menu which couldn't be deleted, but that was able to be removed via "Manage Windows Credentials".


author: madeoninfo
body: For those looking for the **Manage Windows Credentials** , it can be found in **Control Panel\\User Accounts\\Credential Manager** and then just select Windows credentials. My issue was resolved by making sure that the repository URL had the correct login username and password.


author: minnsey
body: Hi  

Do you access repositories using multiple accounts, e.g. access GitHUb repositories under different accounts? If so that can cause the behaviour you are seeing. The 'Git Credentials Manager for Windows' which ships with Git and SourceTree relies on only supports a single account for GitHub and hence constantly prompts the user as it attempts to access repositories under different accounts.  

You can clean out all the cached credentials using the 'Manage Windows Credentials' option in Windows and deleting all entries prefixed by 'git:'  

You can also prevent repeated prompts by disabling SourceTree's automatic checking of remotes in the Tools/Options tab

comments: author: kevin.foley.cda
body: I use one Github account to access all of my repositories on Github, and one Bitbucket account to access all of my Mercurial and Git repositories on Bitbucket.


author: kevin.foley.cda
body: I tried cleaning all of the credentials from the Windows Credentials manager but now the behavior has gotten worse. When the Git Credential Manager login dialog appears and I click Cancel, the Atlassian Bitbucket Login dialog appears. If I click Cancel in this dialog, it re-opens instantly. The only way to make it go away is to close SourceTree and then click Cancel. Now I have to close SourceTree after each commit and not open it again until I'm ready to make another commit, then wait 20 seconds for it to initialize.

SourceTree 1.9 only took a few seconds to initialize, but I can't go back to it due to the huge security flaw that you announced.


Tags: account

authentication

bitbucket