I am trying to download an installation script of a project that is in a Github protected repo.
user
and repo
below are replaced by the correct info.
I have tried curl:
curl -u gabipetrovay -L -o install.sh "https://raw.github.com/user/repo/master/admin/scripts/install.sh"
Curl prompts for the password but as soon as I type the first character it goes further and downloads something (a lot of JS probably from Github)
I also tried wget:
wget --user=gabipetrovay --ask-password "https://raw.github.com/user/repo/master/admin/scripts/install.sh"
With wget I can enter my complete password but then I get a 503 error:
Resolving raw.github.com (raw.github.com)... 199.27.73.133
Connecting to raw.github.com (raw.github.com)|199.27.73.133|:443... connected.
HTTP request sent, awaiting response... 503 Connection timed out
2013-10-14 10:18:45 ERROR 503: Connection timed out.
How can I get the install.sh file? (I am running this from an Ubuntu server 13.04)
And the official response from the Github guys is:
Thanks for getting in touch! For this case, you'll want to use our API to download individual files:
http://developer.github.com/v3/repos/contents/#get-contents
With this endpoint, you can get a specific file like this:
curl -u gabipetrovay -H "Accept: application/vnd.github.raw" "https://api.github.com/repos/user/repo/contents/filename"
You'll just be prompted for your GitHub account password in this case, or you can also use an OAuth token as well. For reference, our API Getting Started Guide has a nice section on authentication:
http://developer.github.com/guides/getting-started/#authentication
And this works like a charm!
Thanks Robert@Github
You can use the V3 API to get a raw file like this (you'll need an OAuth token):
curl -H 'Authorization: token INSERTACCESSTOKENHERE' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/owner/repo/contents/path
All of this has to go on one line. The -O
option saves the file in the current directory. You can use -o filename
to specify a different filename.
To get the OAuth token follow the instructions here: https://help.github.com/articles/creating-an-access-token-for-command-line-use
This allows better automation if you, say, need to do this from a shell script.
I've written this up as a gist as well: https://gist.github.com/madrobby/9476733
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With