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
curl  -L -O

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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
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><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.
adimit19Author Commented:
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.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
According to BitBucket docs, here's how you can use curl...

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.
Price Your IT Services for Profit

Managed service contracts are great - when they're making you money. Yes, you’re getting paid monthly, but is it actually profitable? Learn to calculate your hourly overhead burden so you can master your IT services pricing strategy.

Shaun VermaakTechnical SpecialistCommented:
Why curl? Is the repo so big that you do not want to use git?
adimit19Author Commented:
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.
adimit19Author Commented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.