Skip to content

Instantly share code, notes, and snippets.

@howyi
Created September 7, 2015 11:25
Show Gist options
  • Save howyi/64017704f6b160e22747 to your computer and use it in GitHub Desktop.
Save howyi/64017704f6b160e22747 to your computer and use it in GitHub Desktop.
Authorize and save access token
# coding: utf-8
# python 3.4.3
# tweepy 3.3.0
import webbrowser
import tweepy
import shelve
consumer_key = 'hogehogehoge'
consumer_secret = 'foofoofoo'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
webbrowser.open(auth.get_authorization_url())
pin = input('PIN:').strip()
token = auth.get_access_token(verifier=pin)
auth.set_access_token(token[0],token[1])
dic = shelve.open('account')
dic['account'] = auth
dic.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment