forked from decklin/curlicue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurlicue-setup
executable file
·35 lines (27 loc) · 1.09 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
35
#!/bin/sh
umask 077
if [ $# = 4 ]; then
request_token_url="$1"
authorize_url="$2"
access_token_url="$3"
output_file="$4"
else
echo "usage: $0 REQ_TOKEN_URL AUTHORIZE_URL ACCESS_TOKEN_URL OUTPUT_FILE"
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)
read -p 'Consumer key: ' key
read -p 'Consumer secret: ' secret
echo "oauth_consumer_key=$(curlicue -u "$key")&oauth_consumer_secret=$(
curlicue -u "$secret")" > $consumer_tmp
curlicue -f $consumer_tmp -p 'oauth_callback=oob' -- \
-s -d '' "$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 -d '' "$access_token_url" > $access_token_tmp
paste -d '&' $consumer_tmp $access_token_tmp > "$output_file"
echo "OK! Now you can run: curlicue -f $output_file [-- CURL_OPTS] URL"