From: Josh Roesslein Date: Tue, 29 Sep 2009 06:37:28 +0000 (-0500) Subject: Add an oauth example script. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=17cdae7f50a7ed15c4e8a84cdb0000a32f824c5f;p=tweepy.git Add an oauth example script. --- diff --git a/examples/outh/getaccesstoken.py b/examples/outh/getaccesstoken.py new file mode 100644 index 0000000..1453dd5 --- /dev/null +++ b/examples/outh/getaccesstoken.py @@ -0,0 +1,29 @@ +import webbrowser + +import tweepy + +""" + Query the user for their consumer key/secret + then attempt to fetch a valid access token. +""" + +if __name__ == "__main__": + + consumer_key = raw_input('Consumer key: ').strip() + consumer_secret = raw_input('Consumer secret: ').strip() + auth = tweepy.OAuthHandler(consumer_key, consumer_secret) + + # Open authorization URL in browser + webbrowser.open(auth.get_authorization_url()) + + # Ask user for verifier pin + pin = raw_input('Verification pin number from twitter.com: ').strip() + + # Get access token + token = auth.get_access_token(verifier=pin) + + # Give user the access token + print 'Access token:' + print ' Key: %s' % token.key + print ' Secret: %s' % token.secret +