Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket downloads | In-URL-Authentication for file download

Robin
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!
September 12, 2022

To automate deployment, I need to provide a URL to a file on BitBucket Download.

As the receiving service has no functionality to add a header, the authentication must be included in the URL.

 

For the upload, I can include credentials in this schema (found here, Step 3b):

https://${BITBUCKET_USERNAME}:${BITBUCKET_APP_PASSWORD}@api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads

However, this seems not possible for the download of a file. I tried this schema:

https://${BITBUCKET_USERNAME}:${BITBUCKET_APP_PASSWORD}@api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads/build.zip

 

In this very old post, it sounds like there is a way to get a generated URL, with a 24h-token.

This would be the perfect fit for this use case.

 

Thank you for any hint!

1 answer

1 vote
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 13, 2022

Hey Robin,

Files cannot be downloaded by navigating directly to a URL for the Downloads section of a Bitbucket Repo.

This is because the default method for authentication over HTTPS is username/password which has been deprecated.

You will need to make use of a cURL command to handle this, for example:

curl -L -u username:AppPassword https://api.bitbucket.org/2.0/repositories/{workspace_ID}/{repository_slug}/downloads/filename.ext --output filename.ext

Hope this helps.

Cheers!

- Ben (Bitbucket Cloud Support)

Robin
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!
September 17, 2022

Hey Ben

Thank you for your response.

The only option i have is to send one URL where the service downloads the build. So this doesn't help in this case.

I don't understand why it is not implemented to authenticate this way for the download as it is already possible for the upload.

Thank you & best regards

Robin

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 18, 2022

Hi Robin,

The above that I have specified is to download particular files from the Downloads directory, so apologies for the confusion.

I have tested the below URL format to download builds (ie certain commit hashes) and this has worked from my end - if it does not I would suggest double checking the App Password and updating it if this is not correct:

https://{BITBUCKET_USERNAME}:{BITBUCKET_APP_PASSWORD}@bitbucket.org/{WORKSPACEID}/{REPOSLUG}/get/{COMMITHASH}.zip

 

Hope this helps.

Cheers!

- Ben (Bitbucket Cloud Support)

Adrian
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!
February 19, 2023

Really helpful.

Thank you Ben!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events