Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,363,592
Community Members
 
Community Events
168
Community Groups

Bitbucket downloads | In-URL-Authentication for file download

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

0 votes
Ben Atlassian Team Sep 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)

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 Sep 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)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events