Create Github repository from API
The following works:
(without variables)curl -H "Authorization: token abcdefghijklmnopqrstuvwxyz1234567890abcd"
--data '{"name":"name-foo"}' https://api.github.com/user/repos
(with variables)
NAME='name-foo'
TOK='abcdefghijklmnopqrstuvwxyz1234567890abcd'
BASE='https://api.github.com/'
EXT='user/repos'
URL=$BASE$EXT
curl -H "Authorization: token $TOK" --data "{\"name\":\"$NAME\"}" $URL
One can use personal access tokens instead of OAuth.
The YOUR_TOKEN
value in the "Authorization: token YOUR_TOKEN"
section of the curl
command can be obtained as follows.
- Upper right corner, click User
- Settings
- Personal Access Tokens
- For scopes, select Repos.
- Create New Token.
For more details, click here and here.