Added support for "sign in with twitter" in OAuthHandler.
authorJosh Roesslein <jroesslein@gmail.com>
Mon, 21 Sep 2009 00:10:54 +0000 (19:10 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Mon, 21 Sep 2009 00:10:54 +0000 (19:10 -0500)
CHANGES
tweepy/auth.py

diff --git a/CHANGES b/CHANGES
index bf68daafd3c2c3a44a7cdfe54c49713b8b63df7b..8136b7bf0a4b530a97b81998b9d4481c30a3da77 100644 (file)
--- 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)
 
index 274da5788f92826ee4a684df2e3309f93bfd3536..7f5d8a7476c00902d855f0efd3f8783047ccfef8 100644 (file)
@@ -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()