Updating Git for Windows credentials for Bitbucket app password
Asked Answered
X

2

4

I'm using Git 2.35.1.windows.2 on Windows 10. I understand that this version uses the Windows Credential Manager. Bitbucket recently deprecated the use of the Bitbucket account password for HTTPS Git requests in favor of app passwords.

I have a repository with a Bitbucket remote URL in the form https://[email protected]/example/foobar.git. Yesterday I created a Bitbucket app password. I then went directly into Window Credential and found the credential for git:https://[email protected] and manually set the password to the new app password I created. (I assumed that this changed the credential for git:https://bitbucket.org as well, as both said "Modified: Today".)

However whenever I do a git push for the repository, the response still says:

remote: You are using an account password for Git over HTTPS.
remote: Beginning March 1, 2022, users are required to use app passwords
remote: for Git over HTTPS.
remote: To avoid any disruptions, change the password used in your Git client
remote: to an app password.
remote: Note, these credentials may have been automatically stored in your Git client
remote: and/or a credential manager such as Git Credential Manager (GCM).
remote: More details:
remote: https://bitbucket.org/blog/deprecating-atlassian-account-password-for-bitbucket-api-and-git-activity

Oddly in Windows Credential Manager both the git:https://[email protected] and git:https://bitbucket.org credentials say "Modified: Today", even though I tried to change them to the app password yesterday.

Why didn't my manually updating Windows Credential Manager update the credentials for this repository to the new app password? How is the best way to update to the new app password?

Update 2022-03-12: Atlassian apparently finally disabled using the account password, so when I tried to git push today it popped up a dialog asking for my credentials. I entered the app password in the UI (strangely it talked about SourceTree, when I was using Git from the command line), and finally it accepted the new password. In Windows Credential Manager both the git:https://[email protected] and git:https://bitbucket.org credentials say "Modified: Today". There is a new git:https://[email protected]/refresh_token entry as well.

Now Git on the command line seems to work, but oddly the command still says the following (even though the command succeeds):

fatal: invalid credentials

From a Visual Studio Developer Community comment, though, this may be completely unrelated:

The bitbucket.org part of GCM Core is reporting a “fatal: Invalid credentials” line on the standard error stream, which is what is causing the “Failed to push” error message to appear.

Xylidine answered 21/2, 2022 at 22:44 Comment(2)
I see the exact same message from Bitbucket and have the exact same question. I've switched to the Git Credentials Manager Core. I can't figure out how to get git for Windows to re-prompt me for the password (at which point I assume I'd enter the app password, but I'm not sure yet).Trondheim
Any progress on this? I have same issue.Kristofor
T
4

Here's what worked for me:

  1. Go to Control Panel - Credential Manager - Manage Windows Credentials.

  2. Find the credentials for @bitbucket.org

  3. Choose "Edit" and change the password for them to the app password

Verify via a "git push".

Trondheim answered 23/2, 2022 at 21:58 Comment(3)
How is that procedure different from what I described in the question? Are you saying I have to update git:https://bitbucket.org instead of git:https://[email protected]? Is that the difference?Xylidine
I think I misunderstood your comment about Windows Credential Manager. My apologies. I did see 2 "bitbucket.org" credentials in it, and I changed them both to the app password.Trondheim
One extra note, Visual Studio creates some credentials with the username like PersonalAccessToken. Replace that with your username as well to make this work.Aeroscope
C
1

Make sure that C:\Program Files\Git\mingw64\libexec\git-core is in your PATH, and check what password is associated with your remote server:

printf "host=bitbucket.org\nprotocol=https" | git credential-manager-core get

You might have multiple entries.
To be sure of the result, I would first remove them:

printf "host=bitbucket.org\nprotocol=https" | git credential-manager-core erase

Repeat until you see a prompt asking for your credentials.
Do npt enter them: click Cancel.

Then store your credentials using your app token:

printf "host=bitbucket.org\nprotocol=https\nusername=xxx\npassword=<token>" | git credential-manager-core store.

And you are good to go!

Note: if you have 2FA, you might need to latest GCM v2.0.692, which allows "Sign in with OAuth".

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwf0bRywKVltWVclbw2nZ7-ocVI0bRywWRfQcFyQcC2jaRA/5658207/146974049-dd66c3bf-1291-4c39-b83f-86f13cd1019b.png

Cleres answered 2/4, 2022 at 20:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.