Git for Windows with GCM Core not saving Bitbucket app password

Viewed 133

On a new machine I installed Git for Windows 2.37.1.windows.1, which also installed Git Credential Manager Core 2.0.785+6074e4e3d3. I created a Bitbucket app password. Then I tried to access a private repository on my Bitbucket account using e.g. git pull.

Git popped up an authentication dialog for Bitbucket. It had two options: authenticate with the browser, or authenticate with a password. I tried the password option first. I used my Bitbucket username and my newly created app password. I was able to access the repository.

But when I tried the exact same command, it popped up the authentication dialog again. I did the steps over and over. Each time it allowed me to access the repository, but it appeared the credentials were not being saved.

I opened Credential Manager in Windows and saw credentials for git:https://bitbucket.org.

I tried to access the repository again, but this time I selected the option to authenticate with the browser. It sent me to some web page, and since I was already logged on at the Bitbucket site, it said I was authenticated. I was able to access the repository. And now I am able to access the repository without an authentication dialog each time.

Note that if I create a GitHub personal access token and enter it in the authentication dialog, Git seems to save it so I'm not required to enter it each time.

Why didn't Bitbucket store my credentials? Why did it require me to authenticate through the browser? If I'm forced to authenticate through the browser, what's the point of having an app password? And where is this specific scenario documented?

Update After authenticating with the browser (one of the two options in the "Connect to Bitbucket" authentication dialog in Git for Windows), I was able to continue using Git without further authentication on the Windows 10 Command Prompt. Ah, but then I switched to PowerShell and the whole thing happened all over again: I got the authentication dialog every time I tried to e.g. git push. Each time I was successful with the "Password" option, using my app password, but it never saved the password, requiring me to reenter the password each time.

So once again I chose the "Browser" option in the dialog; it took me to a Bitbucket web page, which said (as I was already logged in):

Authentication Successful Git Credential Manager has been successfully authenticated. You may now close this page.

Now I can git push as much as I like from PowerShell, now that I authenticated using "Browser".

So the question remains: why does Bitbucket's authentication dialog for Git for Windows use the saved app password and instead require that I reenter it each time? (Note that I have since updated to Git for Windows 2.37.2.windows.2.)

3 Answers

using an account password git over https and account password is stored keychain access and use instead of the app

first run the following command :

git config --system credential.helper

git config --global credential.helper

then make a push from the terminal. you should get asked for a password if none is stord keychain access, please provide the app password

this answer has been tried by several people, see this link: https://community.atlassian.com/t5/Bitbucket-questions/Always-seenig-a-mesage-Using-an-account-password-for-Git-over/qaq-p/1919111

First, make sure the issue persists with Git for Windows 2.37.2(2) released 6 days ago (Aug. 12th, 2022)

Second, make sure to register an App password as your password.
(An app password is a user-based access tokens for scripting tasks and integrating tools (such as CI/CD tools) with Bitbucket Cloud).
As explained by "Announcement: Bitbucket Cloud account password usage for Git over HTTPS and API ending March 1, 2022":

If you have saved your credentials (i.e., username and account password) in a credential manager such as Git Credential Manager (GCM), Windows Credential Manager, OS X Keychain, or some other third-party application, then you will need to update them with an app password before March 1, 2022, in order to continue using Basic authentication with the Bitbucket API and/or Git over HTTPS without disruption


Here is how to update GCM with an app password on Windows:

In a CMD, set a simplified PATH like:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set "GH=%LOCALAPPDATA%\Programs\Git"
set "PATH=%GH%\bin;%GH%\cmd;%GH%\usr\bin;%GH%\mingw64\bin;%GH%\mingw64\libexec\git-core;%PATH%"

Then type in the same CMD:

printf "Host=bitbucket.org\nprotocol=https" | git credential-manager-core get
# or 
printf "Host=bitbucket.org\nprotocol=https\nusername=YourBitBucketAccount" | git credential-manager-core get

If you do not see your token (app password for BitBucket Cloud), register it manually:

printf "Host=bitbucket.org\nprotocol=https\nusername=YourBitBucketAccount\npassword=YourAppPassword" | git credential-manager-core store

Then try again, even without cloning, with a git ls-remote https://bitbucket.org/you/YourPrivateRepo.
If it lists branches, the authentication worked.

Have you tried Sourcetree?

I can't count how many hours this program saved me through the years and I don't even have to type 1 command. Its free and made by Atlassian (the same company who made Bitbucket) so you shouldn't have any problem (I use Bitbucket everyday with sourcetree and it works perfectly)

Just make shure you save your ssh privatekey file without password (thank me later)

BTW: For adding accounts: Tools>Options>Authentication and add your accounts

Make sure you enter your ssh privatekey file path under Tools>Options>General>SSH Key this will make sure you don't have to enter any password upon openning the app.

And finally, here is the link you will need to generate a ssh key on Bitbucket: Bitbucket setings>ssh-key

Related