Link to home
Create AccountLog in
Avatar of adimit19
adimit19Flag for Canada

asked on

CURL GET Raw File from BitBucket Repository with security

I am trying to get a raw file from a bitbucket repository using curl with the following commands:

curl  -L -O  https://user:password@bitbucket.org/username/repository/branch/HEAD/filename.txt
curl  -L -O  https://user:password@bitbucket.org/username/repository/branch/raw/filename.txt

I have a file committed to the master branch called filename.txt

I want to get the raw version of the above file. What code do i need to get that? All I get from these commands is the HTML code that the page contains
Avatar of David Favor
David Favor
Flag of United States of America image

URL embedded user/pass credentials haven't worked for years, so won't work on modern Apache installs.

You'll use something similar to this...

curl --digest --user <username>:<password> https://bitbucket.org/<username>/<repository>/get/<branchname>.zip -o <branchname>.zip

Open in new window


The exact form will vary slightly depending on exactly how your repository is setup. Also whether your repository is public/private.

Might be easier to setup an ssh key with an empty passphrase for your repository access.
Avatar of adimit19

ASKER

I can't use --digest --user <username>:<password>. The security info has to be in the https URL because I will be using that URL in another application. I am simply testing it with CURL first.
According to BitBucket docs, here's how you can use curl...

https://developer.atlassian.com/server/bitbucket/how-tos/example-basic-authentication/

You are correct. You must use the REST API for BitBucket access.

Highly unlikely BitBucket allows URL embedded user/pass credentials, as Apache retired this facility years ago.
Why curl? Is the repo so big that you do not want to use git?
Hello David/shaun

David: The syntax works except I can't get the raw format of a single file.

Both: I was hoping to use something like filename.txt?raw instead of the commit key or raw url. I really only need the raw version of a single file and I am stuck on that.

Shaun: I can use git or curl, makes no difference to me. In the end this command will go into another application. Typically the curl command uses the syntax supported by the particular feature in the 3rd party app that I am using.
ASKER CERTIFIED SOLUTION
Avatar of adimit19
adimit19
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer