79

My Bitbucket password is correct because I can easily log in with this password. When I try to push a project or file to Bitbucket it shows "Invalid credentials error".

git push -u origin master

fatal: Invalid credentials
Password for 'https://username@bitbucket.org':
remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication.
remote: See our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231
remote: App passwords are recommended for most use cases and can be created in your Personal settings:
remote: https://bitbucket.org/account/settings/app-passwords/
fatal: Authentication failed for 'https://bitbucket.org/username/demo.git/'

How can I solve this issue?

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Zahidul Islam
  • 1,009
  • 1
  • 6
  • 12
  • 2
    "See our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231" – Joe Mar 07 '22 at 10:33
  • If still error after setup App Password https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/ Update settings remote repository path to this : https://:@bitbucket.org/.git – Ashraf Amin Mar 17 '22 at 03:37
  • @Joe Sorry but your community post is far from being clear ! A simple how-to to would have been better. – user878812 Apr 08 '22 at 08:21

15 Answers15

93

When prompted to log in, use your username, but instead of your usual account password, use the app password:

To get the app password

  1. Go to the bitbucket.org website and log in
  2. From your avatar in the bottom left, and click Personal settings
  3. Click App passwords under Access management
  4. Click Create app password
  5. Give the app password sufficient rights, and a label related to the application that will use the password
  6. Don't forget to save that password
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Asyraf Arifin
  • 957
  • 5
  • 11
31

After 2022-03-01:

Beginning March 1, 2022, you will no longer be able to use your Atlassian account password when using Basic authentication with the Bitbucket Cloud REST API or Git over HTTPS.

  1. Go to: Personal settings, App passwords
  2. Create app password
  3. Tick the necessary permissions for your needs. Account Read and Repositories Read and Write are needed for basic Git actions.
  4. Save the password. You can not view it again!
  5. Use the generated password to log in. You might need to use your Bitbucket username that you can find on Personal settings, Account settings under "Bitbucket profile settings" (saw a post that told specifically to use the username don't know if it is true).

More information about app passwords is on App passwords.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Mikk Raudsepp
  • 311
  • 2
  • 4
  • Now, which are the "necessary permissions for [my] needs"? Using command-line git and have no idea which permissions are necessary beyond 'repositories' read and write??? – leanne Mar 10 '22 at 21:51
  • 1
    Added that part to point nr 3. – Mikk Raudsepp Mar 11 '22 at 12:18
  • Can you add that as an answer, Mikk, to [my SO question here](https://stackoverflow.com/q/71431354/1107226)? (Just the permissions part) – leanne Mar 11 '22 at 14:53
  • This one explained it best. The page i came across in the bitbucket page only explained why it is not supported anymore but does not provide instructions on what to do next. – chitgoks Mar 12 '22 at 06:17
  • 1
    Isn't this backwards? They used to support OAuth, which was both user-friendly and secure. Are you sure you are not misunderstanding something, or the problem is really something else? – Florian Winter Mar 14 '22 at 11:25
19

After successfully creating the app password as mentioned by Asyraf Arifin:

To use Bitbucket "App Password" over HTTPS, you can then navigate to particular repository's path in Terminal then set the remote origin (for an already-cloned repository):

git remote set-url origin https://<Bitbucket_Username>:<App_Password>@bitbucket.org/<Bitbucket_Username>/<Repo_Name>.git

For a new clone:

git clone https://<Bitbucket_Username>:<App_Password>@bitbucket.org/<Bitbucket_Username>/<Repo_Name>.git
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Anish
  • 367
  • 2
  • 10
  • The use of `bitbucket_username` is confusing here. The first is the login username, the 2nd is the BB `accountname` of the repos, thus: "git remote set-url origin https://``:@bitbucket.org/``/.git" – Ray Oei Apr 12 '22 at 11:36
10

I had the same problem in my JetBrains IDE. It was showing a password dialog when I tried updated project sources or push my commits.

enter image description here

I solved the problem by following the below steps

  • Open App Passwords page of personal settings on the Bitbucket enter image description here
  • Click on Create app password and tick at least the read and write permissions of the repositories for the basic pull and push actions. Then give some label and submit by Create. enter image description here
  • The generated app password should be passed in IDE enter image description here

Walia! problem solved.

Artyom Vancyan
  • 2,348
  • 3
  • 10
  • 28
  • 1
    Wow, this works for me, sir !! Tnx – Antolin Bernas Mar 19 '22 at 21:46
  • 1
    @AntolinBernas You're welcome. You could upvote the answer if was helpful to you. That can help others to find their answers more often. – Artyom Vancyan Mar 21 '22 at 13:39
  • For those looking for a solution using VS Code, the idea is pretty similar. When entering the push command a new prompt should appear at the top of the screen saying that you can press 'Enter' to push. This will fail because you are actually supposed to paste the password in the little text box that say 'Password' just above. So you just copy and paste like here and voilá. – Lucas S. G. Apr 16 '22 at 07:05
  • What JetBrains IDE? JetBrains is the name of the company. They have [many IDEs](https://en.wikipedia.org/wiki/JetBrains#IDEs), e.g. [IntelliJ IDEA](https://en.wikipedia.org/wiki/IntelliJ_IDEA), [PhpStorm](https://en.wikipedia.org/wiki/PhpStorm), and [PyCharm](https://en.wikipedia.org/wiki/PyCharm). – Peter Mortensen Apr 23 '22 at 14:59
  • @PeterMortensen It doesn't matter which one, as VCS works the same for all the IDEs listed above. – Artyom Vancyan Apr 24 '22 at 08:08
8

Well, my answer is just a compilation of the Mikk-Raudsepp and Anish answers. They are the real MVPs:

  1. Go to: Personal settings, App passwords

  2. Create app password

  3. Tick the necessary permissions for your needs.

  4. Copy the generated password

  5. On Terminal

    On an already-cloned project:

     git remote set-url origin https://<Bitbucket_Username>:<App_Password>@bitbucket.org/<username/repoName>.git
    

    To clone a new project:

     git clone https://<Bitbucket_Username>:<App_Password>@bitbucket.org/<username/RepoName>.git
    

Why is it happening? -

Beginning March 1, 2022, you will no longer be able to use your Atlassian account password when using Basic authentication with the Bitbucket Cloud REST API or Git over HTTPS.

Mahesh Jamdade
  • 11,710
  • 4
  • 79
  • 97
Fe3back
  • 694
  • 5
  • 12
4
  • Go to Credential ManagerWindows CredentialsAdd a generic credential

  • Fill up the fields:

    • Network address: git:https://bitbucket.org
    • Username:
    • App Password:

It was solved by this question.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Zahidul Islam
  • 1,009
  • 1
  • 6
  • 12
3

If any Linux user is facing the same issue, please follow the steps given below.

  1. Go to bitbucket.org
  2. Click on the Login link
  3. At the bottom left, click on your avatar icon (your profile picture).
  4. Then click Personal settings or you can open Personal settings, Account settings directly
  5. In the Access Management section, click on the App password link or you can go directly to Personal settings, App passwords
  6. Click on the Create App password button.
  7. Give the access rights as per your requirement.
  8. Click on Create.
  9. You get the pop up with a password. Copy that password somewhere in your laptop or pc (the given password will be difficult to remember).
  10. Now whenever you’re are performing a Git operation, like pull or push and if they asked for password. Instead of using your login password, you need to use the above password (one which is generated by the app password).
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Atit More
  • 109
  • 7
3

Go to Personal settings from the menu at the top. Click on App passwords and set up the permissions as required as shown below.

Copy the generated password and use it on the authentication prompt. This will resolve the issue.

Enter image description here

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
sudin
  • 157
  • 1
  • 9
1

I created an app password, made sure the user is username and not email, updated the app password in Windows' Credential Manager, but adding the app password in the repository path finally resolved my issue:

from:

https://username@bitbucket.org/...

to:

https://username:app_password@bitbucket.org/...

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Livshin
  • 15
  • 4
0

For Mac users:

cd Library/Application\ Support/SourceTree

Delete your username here.

You can log in again.

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
0

If using Android Studio, edit your Git remote URL (via Git/Manage Remotes) by adding the new generated app password

https://<Bitbucket_Username>:<App_Password>@bitbucket.org/<Repo_Name>.git

Sneg
  • 166
  • 1
  • 5
0

If there is still an error after setup:

App passwords

Update settings remote repository path to this:

https://<Bitbucket_Username_not_email>:<App_Password_not_old_password>@bitbucket.org/<Full_Repo_Name_Path>.git
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Ashraf Amin
  • 211
  • 2
  • 6
0

Try this passwordless login. With this, you will never need to worry about remembering the password again on your machine (don’t use this technique on public computers)

Set up an SSH key

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Sunil Garg
  • 324
  • 4
  • 7
0

Try creating ssh key and add ssh key to the bitbucket and try

prachi
  • 95
  • 1
  • 7
-3

git remote set-url origin https://<Bitbucket_Username>:<App_Password>@bitbucket.org/<Repo_Name>.git

It worked for me.

Ekim
  • 9
  • 1
  • 2
    This is the same solution as in [this other answer](https://stackoverflow.com/a/71424329/2227743). – Eric Aya Apr 06 '22 at 12:01
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 06 '22 at 12:18