0

I need to be able to create github repositories via bash scripts that run from a php page, so I need to be able to pass the password in the curl command or the API Key.

However I can not seem to find the API key as I believe this may be redundant now with V3 of the github API

I followed Is it possible to create a remote repo on GitHub from the CLI without opening browser? and it got me as far as being prompted for the password

Bash file looks like this:

#! /bin/bash
a=$1
curl="-u 'USERNAME' -p 'PASSWORD' https://api.github.com/user/repos -d '{\"name\":\""$a"\"}'"
curl $curl

This does not work as it is not liking the -p parameter it seems, tried -u 'USERNAME:PASSWORD' and it did not like that either and I can not seem to find the answer on github pages. Ideally I would use the API key as this would not leave my repo password exposed in my bash file correct?

Many thanks

Community
  • 1
  • 1
Fuzzybear
  • 1,378
  • 2
  • 23
  • 39

1 Answers1

2

curl -u 'dmalikov:my_password' https://api.github.com/user/repos -d '{"name":"HI"}' works fine for me, now I have this HI repo.

  • ok the issue seems to be that I want to pass a variable in as the name of the repo. By calling $curl the string it changes the username to be enclosed in ''. Your way works but I now need to find how to pass a variable into the JSON. Many thanks for looking into – Fuzzybear Jul 28 '13 at 14:42
  • Got everything sorted :) for reference I used the command: `curl -u 'USERNME:PASSWORD' https://api.github.com/user/repos -d '{"name":"'"$repoName"'"}'` – Fuzzybear Jul 28 '13 at 15:45