From 5a15aea7abf9d734c0db3bc97914283d3f8b71e2 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Wed, 8 Feb 2012 15:30:11 -0500 Subject: [PATCH] Added git-gh-oauth: script to manage oauth keys for github --- bin/git-gh-oauth | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bin/git-gh-oauth diff --git a/bin/git-gh-oauth b/bin/git-gh-oauth new file mode 100644 index 0000000..30d9b2a --- /dev/null +++ b/bin/git-gh-oauth @@ -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