Announcement: Bitbucket Cloud account password usage for Git over HTTPS and API ending March 1, 2022

283 comments

Scott Marcellus March 17, 2022

I have a process that uses basic auth that now no longer works and trying to get it to work. 

Steps I did.

Created app password that has read access to repository.

I then tried using the code I had before which basically added Authorization Header with the following:

Basic encodedbase64({UserName} + ":" + {Password})

where for UserName I tried both {Bitbucket User Name} and {Bitbucket Username}@bitbucket.org and for Password I used the App password. 

What else can I try to get this working again? All I seem to get downloaded is a generic xml document that is about 7K in size rather than the actual raw file.

 

The code is as follows (powershell):

$RemotePathFile = example only...https://bitbucket.org/{workspace}/{repository}/raw/master/SubfolderA/TestFile.txt

$auth = {not showing...this is encodedbase64({UserName} + ":" + {Password}) listed above}
$auth = 'Basic ' + $auth

$req = New-Object System.Net.WebClient
$req.Headers.Add('Authorization', $auth)

$req.DownloadFile($RemotePathFile, $LocalPathFile)

Milton Plotkin
Contributor
March 17, 2022

For everyone still having trouble:

This took hours to resolve, but worked for me was the following (major thanks to user TrainLayout for step 3 and 5):

  1. Update SourceTree.
  2. Create app password in BitBucket. Make sure the name you give it is entirely lowercase! (When I did these steps, they didn't work until I did this).

  3. Manually delete all credentials in Sourcetree (Tools -> Options -> Authentication).

  4. Delete "C:\Users\<username>\AppData\Local\Atlassian\SourceTree\passwd". Keep SourceTree open while you do this.

  5. Attempt a push, wait for a popup asking for username/password, enter same username as used to create the app password and paste the app password.

Hopefully this should fix things.

Like # people like this
Alan Casalboni March 18, 2022

@Scott Marcellus 

try this way:

change the URL from

https://bitbucket.org/company/repo/download/resource

to 

https://api.bitbucket.org/2.0/repositories/company/repo/download/resource

 

just replace "bitbucket.org" with "api.bitbucket.org/2.0/repositories"

Scott Marcellus March 18, 2022

@Alan Casalboni 

That is definitely getting me closer...I am now at least getting an error rather than a dummy file. The error is "The remote server returned an error: (404) Not Found." And when I use the wrong password I also get the familiar and expected error "The remote server returned an error: (401) Unauthorized."

I suspect there must be something else I have to do to the URL to get this working.

David Dansby
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2022

@brunopostle did you check your app password settings to see if the app password you used was accessed at all (app password settings will show you when your password was last accessed/used)? Also, you will still get the error message if you enter your password wrong. Please ensure you have done the following. 

Here are the steps to show that app passwords work correctly. Please note, I am on a Mac and ensured that my repository is not using a git credential manager so I can be sure I manually enter my app password (this doc has information to determine what git credential manager used for system, global, and local git configs: https://confluence.atlassian.com/bbkb/why-am-i-not-prompted-for-password-when-pushing-or-pulling-to-my-repositories-in-bitbucket-cloud-via-https-800293400.html#:~:text=The%20most%20likely%20reason%20for,c)%20for%20a%20specific%20repository)

  1. create bitbucket account
  2. navigate to Personal settings -> app passwords:
    1. https://bitbucket.org/account/settings/app-passwords/
  3. create app password
    1. select the following scopes
      1. Account:
        1. read and write (tip: just click write to select both)
      2. Repository
        1. read and write (tip: just click write to select both)
    2. Then click create and make sure you correctly write down/save the provided app password
  4. Create a new repository (follow bitbucket prompts to create a new repo)
  5. clone repo via HTTPS
    1. git clone https://<bitbucket_username>@bitbucket.org/<workspace_name>/<repo_name>.git (note <bitbucket_username>, <workspace_name> and <repo_name> will be different for your repository. 

    2. enter this in your terminal
    3. go to the directory of your newly cloned repo (command is: cd dir_name)
  6. Add some stuff to your repo
    1. echo "some stuff" > file.txt
    2. git add .
    3. git commit -m "first commit"
  7. push to Bitbucket cloud remote repo
    1. git push origin master
    2. now your terminal SHOULD ask for your credentials
      1. username: enter your bitbucket cloud username (do not enter your email address; it needs to be your Bitbucket Cloud username)
      2. password: enter your app password created in step 3 above
        1. please ensure you enter app password correctly. 
      3. hit enter and it should push to the Bitbucket Cloud repository

This worked for me with no issue. Let me know if you have any issues trying this out please.

Like brunopostle likes this
David Dansby
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2022

@Scott Marcellus it seems you were trying to hit an internal api (used for website) to download. I suggest utilizing supported, external APIs for API calls. You can find the download API docs here https://developer.atlassian.com/cloud/bitbucket/rest/api-group-downloads/#api-group-downloads

Like Scott Marcellus likes this
brunopostle March 19, 2022

@David Dansbythanks I got this to work by creating a new app-password and following these steps. The old password didn't work, though I'm not sure why, possible reasons:

  • the label included capital letters and hyphens, the working label is lower-case a-z
  • the previous app-password may not have had write permissions, it is impossible to view or edit existing app-password permissions in the web GUI, so I can't be sure about this either

A couple more comments:

  • When using a real app-password that doesn't have correct permissions, the authentication failure message still says remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication [...] This is very misleading as it is reporting an authorisation failure as an authentication failure, leading me to assume the latter
  • It is possible to create multiple app-passwords with the same label, in conjunction with the inability to view permissions, this is very confusing
Like David Dansby likes this
jerome shaolin March 19, 2022

since this change I've been unable to use my repositories in bitbucket! its a disaster!
I  created my app password and saved the provided  password in my password manager to be sure its safe, but entering the correct password  either via git command line or github desktop app gets authentication failure and its impossible to tell why!? (got no reply from atlassian support after a week either!)

Like hausfux likes this
Manisha Deshmukh March 20, 2022

I created app password.  I have been using on my local machine fine.   But when I am using same app password on remote machines,  I get Authentication failed error asking me to create app password. 

Any help @David Dansby ? 

Duncan Groenewald March 20, 2022

This is a mess - Xcode suddenly stopped working yesterday and now I get weird message when trying to use an App password. See below Screen Shot 2022-03-20 at 7.14.22 pm.png

Duncan Groenewald March 20, 2022

OK I finally got Xcode working again by creating a new App password and selected Read/Write for Account, Repository and Pull Requests.

Then I also created a SSH Key and added BitBucket account to Xcode - connected using the App password and then selected SSH and the ssh key.  HTTPS still fails with some authentication error but as long as I use ssh in Xcode is seems to push changes to the remote repo.

Hope this helps someone else.

hausfux March 21, 2022

I can't do anything anymore. I even tried to create a App Password at https://bitbucket.org/account/settings/app-passwords/ but after saving nothing is getting stored.

Jon Mckeever March 21, 2022

@David Dansby Hi David, as per my comments on March 11th, our issue is that when attempting to download a psm1 powershell files from our repository using the powershell command $webClient.DownloadFile, instead of getting the PSM1 file we are after, we get a file named the same as our PSM1 file, but it doesn't contain powershell script, it contains HTML code for a "Something went wrong" Atlassian page.  We are using the bitbucket username (not email) and the app password to do this.  One thing to note is that in our credential set up, the username is followed by a ' escape character.  I believe the original coder of this script did this due to a hyphen being part of the user name.  So the bbcredentials variable I mentioned in my earlier message is set up like this:

  

[String]
$bbCredentials = "user-name`:apppassword",

 

Daniel Tobin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 21, 2022

This transition was handled rather poorly, especially for Sourcetree users considering both Bitbucket and Sourcetree are owned by Atlassian. Right hand not knowing what the left hand is doing?

Like # people like this
David Dansby
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2022

@jerome shaolin when you enter the app password in the git terminal when it asks for your password what is the specific error it gives you back?

David Dansby
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2022

@Manisha Deshmukh can you provide more details. Are you trying to do something different on the remote machines? What is the username you are using on the remote machines (app passwords don't allow using email, they require using the associated Bitbcket Cloud username). Also, did you make sure your priviledge scopes are correct for the app password with regards to what you are trying to use the app password for/to do?

David Dansby
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2022

@hausfux if you provide more details I can try and better assit you. After you create an app password (in your Personal Settings -> app passwords) where are you using your app password? What error message are you getting? Anything else that could determine the issue would be useful as well.

Manisha Deshmukh March 21, 2022

@David Dansby On the remote machine, I am not using credentials cache as its shared by multiple users.  I have to enter username/password for git commands like git pull.    I have added all permissions to my app password.  Same app password works fine with credentials cache on my laptop.

David Dansby
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2022

@Manisha Deshmukh what is the actual error being returned on the remote machine? and to confirm you are correctly entering your username and app password? What privilege scopes are selected for the app password you are using? Also, what is the git remote URL on the remote machine? Does it include an email as the username? Is the username in the git remote URL, and if so, is it the correct username?

Manisha Deshmukh March 21, 2022

@David Dansby 

The git remote url does not have username,  we enter it on the prompt.  

Git remote url :

origin git@bitbucket.org:myco/myrepo.git (fetch)

 

I did use correct username/app password and tries multiple times. 

The error i get:

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/myco/myrepo.git/'

 

 

BTW it worked on one of the remote machines with exact setup but this machine I cant get to work.  I am going to try with SSH-key to see if that helps.

Kennedy March 22, 2022

@David Dansby Do you know who I need to speak with to get support for why username+app_passwords are not working for bitbucket cloud repo type on bamboo? 


  1. I created app passwords for my service accounts and my individual accounts. As a test, the app passwords had full access permissions. These accounts proper access to the repos in question.
  2. I updated the Shared Credentials to use proper username (not email address) and changed the password to the newly created app passwords.
  3. In the Linked Repos, I made sure the proper shared credentials were selected, then clicked "Load Repositories". I will get this error.
    Failed to load data from Bitbucket. [403 Forbidden]

I know there was a warning about cached passwords on the agents, so I made sure to clear the git caches, and wait an hour to a day between retries. 

David Dansby
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 22, 2022

@Kennedy you should be able to make a support case (navigate to this link and at the bottom click the button that says "Log in to contact support): https://support.atlassian.com/bitbucket-cloud/

I believe there should be an option to enter your credentials without using the Stored Credentials; have you tried this as well? Also have you tried removing and then adding the shared credentials back?

Duncan Groenewald March 22, 2022

FYI I was unable to get Xcode to work with HTTPS and the App username/password.  I was able to connect and then had to selected SSH and not HTTPS to get it to work.  Has anyone from Atlassian actually tried using Xcode to verify that their changes are working correctly.  Your SourceTree developers will surely have Xcode experience and can test it for you.  Alternately I am happy to do the testing in conjunction with Atlassian tech team if someone from Atlassian wants to contact me.


Manisha Deshmukh March 22, 2022

@David Dansby  I finally got it working using app password in the repo url like

git pull https://<username>:<apppassword>@bitbucket.org/repo_owner/myrepo.git <branch>

Hope you guys fix the original issue.

Like Shiva Angerekula likes this
Svetlana Sygiainen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 23, 2022

This was an extreme waste of time, patience and nerves. 
I hope you're happy for making me suffer like this. : |

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events