forked from mhayashi1120/Gauche-net-twitter
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a convenience script net/twitauth to get access tokens.
- Loading branch information
Shiro Kawai
committed
Jun 6, 2010
1 parent
bce3ef0
commit 25e0c61
Showing
3 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
;;; | ||
;;; This is a convenience script to obtain access token. | ||
;;; | ||
|
||
(use net.twitter) | ||
(use util.match) | ||
|
||
(define (usage) | ||
(print "Usage: gosh net/twitauth [consumer-key consumer-secret]") | ||
(print " Without arguments, it prompts to enter the application's") | ||
(print " consumer-key and consumer-secret.") | ||
(print " After it obtains a request token, it asks the user to") | ||
(print " visit a twitter url and get a PIN shown there, and promts") | ||
(print " the user to enter the PIN. Then it prints access-token") | ||
(print " and access-token-secret, with consumer-key and consumer-secret,") | ||
(print " to the stdout. Copy them to your application settings to") | ||
(print " to access Twitter by the application on behalf of the user.") | ||
(exit 0)) | ||
|
||
(define (main args) | ||
(match (cdr args) | ||
[() | ||
(display "Enter consumer key: ") (flush) | ||
(let1 key (read-line) | ||
(when (eof-object? key) (exit 1 "aborted.")) | ||
(display "Enter consumer secret: ") (flush) | ||
(let1 secret (read-line) | ||
(when (eof-object? secret) (exit 1 "aborted.")) | ||
(report (twitter-authenticate-client key secret))))] | ||
[(key secret) (report (twitter-authenticate-client key secret))] | ||
[_ (usage)]) | ||
0) | ||
|
||
(define (report cred) | ||
(print "(") | ||
(print " (consumer-key . \""(ref cred'consumer-key)"\")") | ||
(print " (consumer-secret . \""(ref cred'consumer-secret)"\")") | ||
(print " (access-token . \""(ref cred'access-token)"\")") | ||
(print " (access-token-secret . \""(ref cred'access-token-secret)"\")") | ||
(print ")")) | ||
|