From: Mike Verdone Date: Sat, 15 May 2010 21:50:25 +0000 (+0200) Subject: twitterbot oauth in progress X-Git-Tag: twitter-1.4~8^2~4 X-Git-Url: https://jfr.im/git/z_archive/twitter.git/commitdiff_plain/ddeba1648426ffe018211dba5f7b92bdd3d1c007?hp=b313a2b437bfe0905ff3c6d49a43df91b6c5094b twitterbot oauth in progress --- diff --git a/twitter/cmdline.py b/twitter/cmdline.py index 980b754..e7a73cb 100644 --- a/twitter/cmdline.py +++ b/twitter/cmdline.py @@ -447,15 +447,6 @@ class DoNothingAction(Action): def __call__(self, twitter, options): pass -def parse_oauth_tokens(result): - for r in result.split('&'): - k, v = r.split('=') - if k == 'oauth_token': - oauth_token = v - elif k == 'oauth_token_secret': - oauth_token_secret = v - return oauth_token, oauth_token_secret - actions = { 'authorize' : DoNothingAction, 'follow' : FollowAction, diff --git a/twitter/oauth_dance.py b/twitter/oauth_dance.py index cffa624..dcbcc6a 100644 --- a/twitter/oauth_dance.py +++ b/twitter/oauth_dance.py @@ -1,4 +1,6 @@ +import webbrowser +import time from api import Twitter from oauth import OAuth, write_token_file @@ -36,14 +38,23 @@ type it here: oauth_verifier = raw_input("Please type the PIN: ").strip() twitter = Twitter( auth=OAuth( - oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMER_SECRET), + oauth_token, oauth_token_secret, consumer_key, consumer_secret), format='') oauth_token, oauth_token_secret = parse_oauth_tokens( twitter.oauth.access_token(oauth_verifier=oauth_verifier)) if token_filename: write_token_file( token_filename, oauth_token, oauth_token_secret) - print - print "That's it! Your authorization keys have been written to %s." % ( - options['oauth_filename']) + print + print "That's it! Your authorization keys have been written to %s." % ( + token_filename) + return oauth_token, oauth_token_secret + +def parse_oauth_tokens(result): + for r in result.split('&'): + k, v = r.split('=') + if k == 'oauth_token': + oauth_token = v + elif k == 'oauth_token_secret': + oauth_token_secret = v return oauth_token, oauth_token_secret