From: Josh Roesslein Date: Mon, 21 Sep 2009 00:10:54 +0000 (-0500) Subject: Added support for "sign in with twitter" in OAuthHandler. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5b8d9bfba7196ad50744adb436911f7596ec1a0b;p=tweepy.git Added support for "sign in with twitter" in OAuthHandler. --- diff --git a/CHANGES b/CHANGES index bf68daa..8136b7b 100644 --- a/CHANGES +++ b/CHANGES @@ -7,7 +7,12 @@ during upgrade will be listed here. + Google App Engine fixes (thanks Thomas Bohmbach, Jr) + Added Retweet API methods + Added Retweet Streaming method -+ Added set_request_token() method to OAuthHandler ++ OAuthHandler + + Added set_request_token() method + + Added support for "sign in with twitter". + get_authorization_url() now takes a boolean that when + true uses the "sign in with twitter" flow. + See http://apiwiki.twitter.com/Sign-in-with-Twitter + Examples + Appengine demo (oauth) diff --git a/tweepy/auth.py b/tweepy/auth.py index 274da57..7f5d8a7 100644 --- a/tweepy/auth.py +++ b/tweepy/auth.py @@ -30,6 +30,7 @@ class OAuthHandler(AuthHandler): REQUEST_TOKEN_URL = 'http://twitter.com/oauth/request_token' AUTHORIZATION_URL = 'http://twitter.com/oauth/authorize' + AUTHENTICATE_URL = 'http://twitter.com/oauth/authenticate' ACCESS_TOKEN_URL = 'http://twitter.com/oauth/access_token' def __init__(self, consumer_key, consumer_secret, callback=None): @@ -64,15 +65,19 @@ class OAuthHandler(AuthHandler): def set_access_token(self, key, secret): self.access_token = oauth.OAuthToken(key, secret) - def get_authorization_url(self): + def get_authorization_url(self, signin_with_twitter=False): """Get the authorization URL to redirect the user""" try: # get the request token self.request_token = self._get_request_token() # build auth request and return as url + if signin_with_twitter: + auth_url = self.AUTHENTICATE_URL + else: + auth_url = self.AUTHORIZATION_URL request = oauth.OAuthRequest.from_token_and_callback( - token=self.request_token, http_url=self.AUTHORIZATION_URL + token=self.request_token, http_url=auth_url ) return request.to_url()