Commit 5b8d9bfb authored by Josh Roesslein's avatar Josh Roesslein
Browse files

Added support for "sign in with twitter" in OAuthHandler.

parent fef7e054
......@@ -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)
......
......@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment