mirror of
https://github.com/tj/git-extras.git
synced 2026-09-15 09:56:19 -04:00
Added git-gh-oauth: script to manage oauth keys for github
This commit is contained in:
parent
6ae2ba17ff
commit
5a15aea7ab
17
bin/git-gh-oauth
Normal file
17
bin/git-gh-oauth
Normal 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
|
||||
Loading…
Reference in a new issue