-
Notifications
You must be signed in to change notification settings - Fork 12
/
curlicue-setup
executable file
·34 lines (26 loc) · 1.16 KB
/
curlicue-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
umask 077
if [ $# = 4 ]; then
request_token_url="$1"
authorize_url="$2"
access_token_url="$3"
output_creds="$4"
else
echo "usage: $0 REQ_TOKEN_URL AUTHORIZE_URL ACCESS_TOKEN_URL OUTPUT_CREDS"
exit 2
fi
consumer_tmp=$(mktemp -t curlicue_consumer.XXXXXX)
request_token_tmp=$(mktemp -t curlicue_request_token.XXXXXX)
access_token_tmp=$(mktemp -t curlicue_access_token.XXXXXX)
trap "rm -f '$consumer_tmp' '$request_token_tmp' '$access_token_tmp'" EXIT
read -p 'Consumer key: ' key
read -p 'Consumer secret: ' secret
curl-encode "oauth_consumer_key=$key" "oauth_consumer_secret=$secret" > "$consumer_tmp"
curlicue -f "$consumer_tmp" -p 'oauth_callback=oob' -- \
-s -X POST "$request_token_url" > "$request_token_tmp"
echo "Load this URL: $(curlicue -f "$consumer_tmp" -f "$request_token_tmp" -e "$authorize_url")"
read -p 'Paste the PIN you got here: ' pin
curlicue -f "$consumer_tmp" -f "$request_token_tmp" ${pin:+-p "oauth_verifier=$pin"} -- \
-s -X POST "$access_token_url" > "$access_token_tmp"
paste -d '&' "$consumer_tmp" "$access_token_tmp" > "$output_creds"
echo "OK! Now you can run: curlicue -f $output_creds [-- CURL_OPTS] URL"