Download file from bucket using App-Password
Asked by Christophe Faribault:

Hi!

I'm building an automated deploymnet for an app and part of it uses the bucket "Downloads" to upload the app build file. I can upload the file using the App-Password but the download doesn't work. Not that I get an error, I just don't get any content from the HTTP request. Auth is fine. The App-Password has Read/Write permissions for "Repositories". I really don't know what I'm missing here.

Any idea?

Thanks!


Answers:
author: Ben
body: Hey Christophe,

May I see the cURL command you are executing? Just redact the sensitive information, ie App Password/username/workspaceID/reposlug as this is a public forum.

Cheers!

- Ben (Bitbucket Cloud Support)

comments: author: Christophe Faribault
body: Hi [@Ben](/t5/user/viewprofilepage/user-id/4537226) ,

Here:

curl -H "Authorization: Basic \*\*\*\*\*" [https://api.bitbucket.org/2.0/repositories/\*\*\*\*\*/\*\*\*\*\*/downloads/latest.yml](https://api.bitbucket.org/2.0/repositories/*****/*****/downloads/latest.yml) --verbose

Here is also the output of the command:  

\* Trying 18.205.93.6:443...  
\* Connected to api.bitbucket.org (18.205.93.6) port 443 (#0)  
\* ALPN, offering h2  
\* ALPN, offering http/1.1  
\* CAfile: /etc/ssl/certs/ca-certificates.crt  
\* CApath: /etc/ssl/certs  
\* TLSv1.0 (OUT), TLS header, Certificate Status (22):  
\* TLSv1.3 (OUT), TLS handshake, Client hello (1):  
\* TLSv1.2 (IN), TLS header, Certificate Status (22):  
\* TLSv1.3 (IN), TLS handshake, Server hello (2):  
\* TLSv1.2 (OUT), TLS header, Finished (20):  
\* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):  
\* TLSv1.2 (OUT), TLS header, Certificate Status (22):  
\* TLSv1.3 (OUT), TLS handshake, Client hello (1):  
\* TLSv1.2 (IN), TLS header, Finished (20):  
\* TLSv1.2 (IN), TLS header, Certificate Status (22):  
\* TLSv1.3 (IN), TLS handshake, Server hello (2):  
\* TLSv1.2 (IN), TLS header, Supplemental data (23):  
\* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):  
\* TLSv1.2 (IN), TLS header, Supplemental data (23):  
\* TLSv1.3 (IN), TLS handshake, Certificate (11):  
\* TLSv1.2 (IN), TLS header, Supplemental data (23):  
\* TLSv1.3 (IN), TLS handshake, CERT verify (15):  
\* TLSv1.2 (IN), TLS header, Supplemental data (23):  
\* TLSv1.3 (IN), TLS handshake, Finished (20):  
\* TLSv1.2 (OUT), TLS header, Supplemental data (23):  
\* TLSv1.3 (OUT), TLS handshake, Finished (20):  
\* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256  
\* ALPN, server accepted to use h2  
\* Server certificate:  
\* subject: C=US; ST=California; L=San Francisco; O=Atlassian US, Inc.; CN=\*.bitbucket.org  
\* start date: Apr 28 00:00:00 2023 GMT  
\* expire date: Mar 28 23:59:59 2024 GMT  
\* subjectAltName: host "api.bitbucket.org" matched cert's "\*.bitbucket.org"  
\* issuer: C=US; O=DigiCert Inc; OU=[www.digicert.com](http://www.digicert.com); CN=DigiCert SHA2 High Assurance Server CA  
\* SSL certificate verify ok.  
\* Using HTTP2, server supports multiplexing  
\* Connection state changed (HTTP/2 confirmed)  
\* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0  
\* TLSv1.2 (OUT), TLS header, Supplemental data (23):  
\* TLSv1.2 (OUT), TLS header, Supplemental data (23):  
\* TLSv1.2 (OUT), TLS header, Supplemental data (23):  
\* Using Stream ID: 1 (easy handle 0x56162ee8be90)  
\* TLSv1.2 (OUT), TLS header, Supplemental data (23):  
\> GET /2.0/repositories/\*\*\*\*\*/\*\*\*\*\*/downloads/latest.yml HTTP/2  
\> Host: api.bitbucket.org  
\> user-agent: curl/7.81.0  
\> accept: \*/\*  
\> authorization: Basic \*\*\*\*\*  
\>  
\* TLSv1.2 (IN), TLS header, Supplemental data (23):  
\* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):  
\* TLSv1.2 (IN), TLS header, Supplemental data (23):  
\* Connection state changed (MAX_CONCURRENT_STREAMS == 32)!  
\* TLSv1.2 (OUT), TLS header, Supplemental data (23):  
\* TLSv1.2 (IN), TLS header, Supplemental data (23):  
\< HTTP/2 302  
\< server: envoy  
\< vary: Authorization, Origin  
\< content-type: text/html; charset=utf-8  
\< x-oauth-scopes: repository:admin, repository:write  
\< x-b3-traceid: 6d45b0e3e38dccf7  
\< x-usage-output-ops: 0  
\< x-used-mesh: False  
\< x-dc-location: Micros-3  
\< strict-transport-security: max-age=31536000; includeSubDomains; preload  
\< date: Fri, 12 May 2023 21:49:13 GMT  
\< x-request-id: 6d45b0e3e38dccf7  
\< x-usage-user-time: 0.241203  
\< x-usage-system-time: 0.029486  
\< location: [https://bbuseruploads.s3.amazonaws.com/1b1e8c88-3791-46fd-b897-172861593630/downloads/ae5d9149-2fe6-47be-849d-6b1ec9ccfd7c/latest.yml?response-content-disposition=attachment%3B%20filename%3D%22latest.yml%22\&AWSAccessKeyId=ASIA6KOSE3BNN7H3CJ4C\&Signature=ehlBSszZ6nldUK89piF5zb2CYdg%3D\&x-amz-security-token=FwoGZXIvYXdzEL%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDIBRCzhYbYLZKSo1eCK6AYuOiqIQ%2Ft6H6n4EXWsoZeNAyd5CvPkSTD8YU0g2NL1SvAjrcWfcH7ZbFblSWGQL5%2FK9sBrdQCABNgNQnWc8EkzZEKOoWc2%2BJzGz%2FQH5PPKtxVjz8IfHK...](https://bbuseruploads.s3.amazonaws.com/1b1e8c88-3791-46fd-b897-172861593630/downloads/ae5d9149-2fe6-47be-849d-6b1ec9ccfd7c/latest.yml?response-content-disposition=attachment%3B%20filename%3D%22latest.yml%22&AWSAccessKeyId=ASIA6KOSE3BNN7H3CJ4C&Signature=ehlBSszZ6nldUK89piF5zb2CYdg%3D&x-amz-security-token=FwoGZXIvYXdzEL%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDIBRCzhYbYLZKSo1eCK6AYuOiqIQ%2Ft6H6n4EXWsoZeNAyd5CvPkSTD8YU0g2NL1SvAjrcWfcH7ZbFblSWGQL5%2FK9sBrdQCABNgNQnWc8EkzZEKOoWc2%2BJzGz%2FQH5PPKtxVjz8IfHKfB4XK6GMqP04I3GqRxSeCVzCa9Tr07uHzRwcYjkuMohwdwh98Yw%2Fol0m2b%2ForwEo%2BP222RpXqv9YzAdrjWlfCeWkXfZ7xuBSbTuohccZ9ONRwBmI8JPn4V9CKygLUQrU6gdBSjZ6PqiBjItJueEzXRAm8LHg9tdqwZ%2BeNNIK1rTvoeedyuNlgn0dcy0Zn0XBdUeupNy24BG&Expires=1683929953)  
\< x-served-by: f7a3638646af  
\< x-xss-protection: 1; mode=block  
\< x-envoy-upstream-service-time: 396  
\< x-view-name: bitbucket.apps.downloads.api.v20.handlers.DownloadHandler  
\< x-static-version: 582cfc3be6d7  
\< etag: "d41d8cd98f00b204e9800998ecf8427e"  
\< x-content-type-options: nosniff  
\< x-accepted-oauth-scopes: repository  
\< x-credential-type: apppassword  
\< x-render-time: 0.3852379322052002  
\< x-trace-id: 6d45b0e3e38dccf7  
\< x-usage-input-ops: 0  
\< x-frame-options: SAMEORIGIN  
\< x-version: 582cfc3be6d7  
\< x-request-count: 1368  
\< content-length: 0  
\<  
\* Connection #0 to host api.bitbucket.org left intact


author: Ben
body: Hi [@Christophe Faribault](/t5/user/viewprofilepage/user-id/5026731)

You're almost there! You're just missing the --output flag and some other indicators to specify what to export the file as, the command will not work without this.

I've just tested the below command and this will get you what you need:

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


author: Christophe Faribault
body: Hi [@Ben](/t5/user/viewprofilepage/user-id/4537226)

It seems the "-L" is the culprit specifically. The "--output" is not necessary to just receive the file content.

Thanks for pointing me in the right direction! I'm using a 3rd-party library for this so I'll get in touch with the developers to understand why it's not working.

Thanks again!


Tags: bitbucket-cloud

cloud