Skip to content

Instantly share code, notes, and snippets.

@fourdollars
Last active August 1, 2018 21:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fourdollars/6027400 to your computer and use it in GitHub Desktop.
Save fourdollars/6027400 to your computer and use it in GitHub Desktop.
A simple shell script to get OAuth tokens from https://launchpad.net/ .
#!/bin/sh
oauth_consumer_key='just+testing'
for x in $(wget -q --post-data "oauth_consumer_key=$oauth_consumer_key&oauth_signature_method=PLAINTEXT&oauth_signature=%26" https://launchpad.net/+request-token -O - | sed 's/&/ /g'); do
case "$x" in
(oauth_token=*)
oauth_token="${x#*=}"
;;
(oauth_token_secret=*)
oauth_token_secret="${x#*=}"
;;
esac
done
xdg-open "https://launchpad.net/+authorize-token?oauth_token=$oauth_token"
read -p 'Press Enter after authorized... ' blah
for x in $(wget -q --post-data "oauth_consumer_key=$oauth_consumer_key&oauth_token=$oauth_token&oauth_signature_method=PLAINTEXT&oauth_signature=%26$oauth_token_secret" https://launchpad.net/+access-token -O - | sed 's/&/ /g'); do
case "$x" in
(oauth_token=*)
oauth_token="${x#*=}"
;;
(oauth_token_secret=*)
oauth_token_secret="${x#*=}"
;;
(lp.context=*)
if [ "${x#*=}" = 'None' ]; then
echo "oauth_token $oauth_token"
echo "oauth_token_secret $oauth_token_secret"
fi
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment