From 2d34e23619a39b212f4d71373323880f106f1ba9 Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 27 Jan 2020 23:43:24 +0800 Subject: update --- scripts/gist | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index f0816e5..6d58fe7 100755 --- a/scripts/gist +++ b/scripts/gist @@ -61,24 +61,14 @@ config=~/.config/gistrc set -eo pipefail [ "$TRACE" ] && set -x -# TODO error handling while password is not true -# TODO support access token from input or web _auth() { - local data="{\"scopes\":[\"gist\"], \"note\": \"gist-$(date -u +'%Y-%m-%dT%H:%M:%SZ')\"}" read -p "Github username: " user < /dev/tty - read -sp "Github password: " password < /dev/tty mkdir -p ~/.config && umask 0077 && echo user=$user > $config + echo "Create a new token from web browser" + python -mwebbrowser https://github.com/settings/tokens/new\?scopes\=gist - curl -i https://api.github.com/authorizations \ - --user "$user:$password" \ - --data "$data" - - read -p "2-factor code: " OTP < /dev/tty - curl https://api.github.com/authorizations \ - --user "$user:$password" -H "X-GitHub-OTP: $OTP" \ - --data "$data" \ - | sed '1 s/[^{]//g' | jq -r .token \ - | sed 's/^/token=/' >> $config + read -p "Paste your token here: " new_token < /dev/tty + echo token=$new_token >> $config } case "$1" in -- cgit v1.2.3-70-g09d2