Added git-gh-oauth: script to manage oauth keys for github

This commit is contained in:
David Baumgold 2012-02-08 15:30:11 -05:00
parent 6ae2ba17ff
commit 5a15aea7ab

17
bin/git-gh-oauth Normal file
View file

@ -0,0 +1,17 @@
#!/bin/sh
user=`git config github.user`
test -z "$user" && echo "failed to fetch github.user" 1>&2 && exit 1
oauthToken=`git config github.oauthToken`
if [ -z $oauthToken ] ; then
echo "Github oAuth token not found. Creating a new one."
stty_orig=`stty -g`
stty -echo
printf "Github password:"
read passwd
stty $stty_orig
url="https://api.github.com/authorizations"
oauthToken=$(curl -# -u "$user:$passwd" $url -d '{"scopes": ["repo", "user", "gist"]}' | jshon -e token | sed -e 's/"//g')
git config --global github.oauthToken $oauthToken
fi
echo $oauthToken