Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Twitter OAuth handler (gae/py, webapp2, tweepy)
import webapp2, tweepy
consumer_token = 'CONSUMER KEY'
consumer_secret = 'CONSUMER SECRET'
auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
class Twitter(webapp2.RequestHandler):
def get(self):
oauth_token = self.request.get("oauth_token")
oauth_verifier = self.request.get("oauth_verifier")
if oauth_token:
api = tweepy.API(auth)
me =
self.response.write('Hi %s!' %
auth_url = auth.get_authorization_url()
self.response.write("<a href='%s'>Twitter login</a>" % auth_url)
app = webapp2.WSGIapplication([('/', Twitter)])
def main():
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment