From 99a6dccbce2fea77689475b18b411f49cc97d076 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 5 Apr 2013 00:12:54 +0200 Subject: [PATCH 1/3] added oauth_verifier arg --- twython/twython.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/twython/twython.py b/twython/twython.py index cddf739..cd724a3 100644 --- a/twython/twython.py +++ b/twython/twython.py @@ -81,7 +81,7 @@ class TwythonRateLimitError(TwythonError): class Twython(object): - def __init__(self, app_key=None, app_secret=None, oauth_token=None, oauth_token_secret=None, \ + def __init__(self, app_key=None, app_secret=None, oauth_token=None, oauth_token_secret=None, oauth_verifier=None, \ headers=None, callback_url=None, twitter_token=None, twitter_secret=None, proxies=None, version='1.1'): """Instantiates an instance of Twython. Takes optional parameters for authentication and such (see below). @@ -110,6 +110,8 @@ class Twython(object): self.callback_url = callback_url + self.oauth_verifier = oauth_verifier + # If there's headers, set them, otherwise be an embarassing parent for their own good. self.headers = headers or {'User-Agent': 'Twython v' + __version__} @@ -306,7 +308,7 @@ class Twython(object): def get_authorized_tokens(self): """Returns authorized tokens after they go through the auth_url phase. """ - response = self.client.get(self.access_token_url) + response = self.client.get(self.access_token_url,params={'oauth_verifier' : self.oauth_verifier}) authorized_tokens = dict(parse_qsl(response.content)) if not authorized_tokens: raise TwythonError('Unable to decode authorized tokens.') From 26b3a232d0be46ce17920bca287260ec8eca43bc Mon Sep 17 00:00:00 2001 From: hansenrum Date: Fri, 5 Apr 2013 00:25:23 +0200 Subject: [PATCH 2/3] oauth_verifier fix --- twython/twython.py | 1 - 1 file changed, 1 deletion(-) diff --git a/twython/twython.py b/twython/twython.py index cd724a3..e9f701c 100644 --- a/twython/twython.py +++ b/twython/twython.py @@ -109,7 +109,6 @@ class Twython(object): self.oauth_token_secret = oauth_token_secret and u'%s' % oauth_token_secret self.callback_url = callback_url - self.oauth_verifier = oauth_verifier # If there's headers, set them, otherwise be an embarassing parent for their own good. From 1eb1bd080d88e35b13de355926e64a14ebe767a7 Mon Sep 17 00:00:00 2001 From: hansenrum Date: Fri, 5 Apr 2013 18:36:58 +0200 Subject: [PATCH 3/3] moved oauth_verifier from init to method --- twython/twython.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/twython/twython.py b/twython/twython.py index e9f701c..2e27ee5 100644 --- a/twython/twython.py +++ b/twython/twython.py @@ -81,7 +81,7 @@ class TwythonRateLimitError(TwythonError): class Twython(object): - def __init__(self, app_key=None, app_secret=None, oauth_token=None, oauth_token_secret=None, oauth_verifier=None, \ + def __init__(self, app_key=None, app_secret=None, oauth_token=None, oauth_token_secret=None, \ headers=None, callback_url=None, twitter_token=None, twitter_secret=None, proxies=None, version='1.1'): """Instantiates an instance of Twython. Takes optional parameters for authentication and such (see below). @@ -109,7 +109,6 @@ class Twython(object): self.oauth_token_secret = oauth_token_secret and u'%s' % oauth_token_secret self.callback_url = callback_url - self.oauth_verifier = oauth_verifier # If there's headers, set them, otherwise be an embarassing parent for their own good. self.headers = headers or {'User-Agent': 'Twython v' + __version__} @@ -304,10 +303,10 @@ class Twython(object): return request_tokens - def get_authorized_tokens(self): + def get_authorized_tokens(self, oauth_verifier): """Returns authorized tokens after they go through the auth_url phase. """ - response = self.client.get(self.access_token_url,params={'oauth_verifier' : self.oauth_verifier}) + response = self.client.get(self.access_token_url, params={'oauth_verifier' : oauth_verifier}) authorized_tokens = dict(parse_qsl(response.content)) if not authorized_tokens: raise TwythonError('Unable to decode authorized tokens.')