This file looks large and may slow your browser down if we attempt
to syntax highlight it, so we are showing it without any
pretty colors.
Highlight
it anyway.
| 1 |
import webbrowser |
| 2 |
|
| 3 |
import tweepy |
| 4 |
|
| 5 |
""" |
| 6 |
Query the user for their consumer key/secret |
| 7 |
then attempt to fetch a valid access token. |
| 8 |
""" |
| 9 |
|
| 10 |
if __name__ == "__main__": |
| 11 |
|
| 12 |
consumer_key = raw_input('Consumer key: ').strip() |
| 13 |
consumer_secret = raw_input('Consumer secret: ').strip() |
| 14 |
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) |
| 15 |
|
| 16 |
# Open authorization URL in browser |
| 17 |
webbrowser.open(auth.get_authorization_url()) |
| 18 |
|
| 19 |
# Ask user for verifier pin |
| 20 |
pin = raw_input('Verification pin number from twitter.com: ').strip() |
| 21 |
|
| 22 |
# Get access token |
| 23 |
token = auth.get_access_token(verifier=pin) |
| 24 |
|
| 25 |
# Give user the access token |
| 26 |
print 'Access token:' |
| 27 |
print ' Key: %s' % token.key |
| 28 |
print ' Secret: %s' % token.secret |