Merge 62b984eb61 into 8ecc55b5ad
This commit is contained in:
commit
59530aa5d1
3 changed files with 11 additions and 4 deletions
|
|
@ -35,6 +35,7 @@ Patches and Suggestions
|
||||||
- `Terry Jones <https://github.com/terrycojones>`_, Error cleanup and Exception processing in 2.3.0.
|
- `Terry Jones <https://github.com/terrycojones>`_, Error cleanup and Exception processing in 2.3.0.
|
||||||
- `Leandro Ferreira <https://github.com/leandroferreira>`_, Fix for double-encoding of search queries in 2.3.0.
|
- `Leandro Ferreira <https://github.com/leandroferreira>`_, Fix for double-encoding of search queries in 2.3.0.
|
||||||
- `Chris Brown <https://github.com/chbrown>`_, Updated to use v1.1 endpoints over v1
|
- `Chris Brown <https://github.com/chbrown>`_, Updated to use v1.1 endpoints over v1
|
||||||
- `Virendra Rajput <https://github.com/bkvirendra>`_, Fixed unicode (json) encoding in twython.py 2.7.2.
|
- `Virendra Rajput <https://github.com/bkvirendra>`_, Fixed unicode (json) encoding in twython.py 2.7.2.
|
||||||
- `Paul Solbach <https://github.com/hansenrum>`_, fixed requirement for oauth_verifier
|
- `Paul Solbach <https://github.com/hansenrum>`_, fixed requirement for oauth_verifier
|
||||||
- `Greg Nofi <https://github.com/nofeet>`_, fixed using built-in Exception attributes for storing & retrieving error message
|
- `Greg Nofi <https://github.com/nofeet>`_, fixed using built-in Exception attributes for storing & retrieving error message
|
||||||
|
- `Jonathan Vanasco <https://github.com/jvanasco>`_, Debugging support, error_code tracking, Twitter error API tracking, other fixes
|
||||||
|
|
|
||||||
4
CHANGES.txt
Normal file
4
CHANGES.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
2013-04-23 (jvanasco)
|
||||||
|
- added ssl_verify param to Twython config.
|
||||||
|
option defaults to `True` and is proxied to the `requests` library client
|
||||||
|
can be set to `False`, which better supports local testing
|
||||||
|
|
@ -34,7 +34,7 @@ except ImportError:
|
||||||
|
|
||||||
class Twython(object):
|
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,
|
||||||
headers=None, callback_url=None, twitter_token=None, twitter_secret=None, proxies=None, version='1.1'):
|
headers=None, callback_url=None, twitter_token=None, twitter_secret=None, proxies=None, version='1.1', ssl_verify=True ):
|
||||||
"""Instantiates an instance of Twython. Takes optional parameters for authentication and such (see below).
|
"""Instantiates an instance of Twython. Takes optional parameters for authentication and such (see below).
|
||||||
|
|
||||||
:param app_key: (optional) Your applications key
|
:param app_key: (optional) Your applications key
|
||||||
|
|
@ -44,6 +44,7 @@ class Twython(object):
|
||||||
:param headers: (optional) Custom headers to send along with the request
|
:param headers: (optional) Custom headers to send along with the request
|
||||||
:param callback_url: (optional) If set, will overwrite the callback url set in your application
|
:param callback_url: (optional) If set, will overwrite the callback url set in your application
|
||||||
:param proxies: (optional) A dictionary of proxies, for example {"http":"proxy.example.org:8080", "https":"proxy.example.org:8081"}.
|
:param proxies: (optional) A dictionary of proxies, for example {"http":"proxy.example.org:8080", "https":"proxy.example.org:8081"}.
|
||||||
|
:param ssl_verify: (optional, default True) Turns off ssl verifiction, for when you have development server issues.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Needed for hitting that there API.
|
# Needed for hitting that there API.
|
||||||
|
|
@ -52,6 +53,7 @@ class Twython(object):
|
||||||
self.request_token_url = self.api_url % 'oauth/request_token'
|
self.request_token_url = self.api_url % 'oauth/request_token'
|
||||||
self.access_token_url = self.api_url % 'oauth/access_token'
|
self.access_token_url = self.api_url % 'oauth/access_token'
|
||||||
self.authenticate_url = self.api_url % 'oauth/authenticate'
|
self.authenticate_url = self.api_url % 'oauth/authenticate'
|
||||||
|
self.ssl_verify = ssl_verify
|
||||||
|
|
||||||
# Enforce unicode on keys and secrets
|
# Enforce unicode on keys and secrets
|
||||||
self.app_key = app_key and unicode(app_key) or twitter_token and unicode(twitter_token)
|
self.app_key = app_key and unicode(app_key) or twitter_token and unicode(twitter_token)
|
||||||
|
|
@ -238,7 +240,7 @@ class Twython(object):
|
||||||
if self.callback_url:
|
if self.callback_url:
|
||||||
request_args['oauth_callback'] = self.callback_url
|
request_args['oauth_callback'] = self.callback_url
|
||||||
|
|
||||||
response = self.client.get(self.request_token_url, params=request_args)
|
response = self.client.get(self.request_token_url, params=request_args, verify=self.ssl_verify)
|
||||||
if response.status_code == 401:
|
if response.status_code == 401:
|
||||||
raise TwythonAuthError(response.content, error_code=response.status_code)
|
raise TwythonAuthError(response.content, error_code=response.status_code)
|
||||||
elif response.status_code != 200:
|
elif response.status_code != 200:
|
||||||
|
|
@ -271,7 +273,7 @@ class Twython(object):
|
||||||
def get_authorized_tokens(self, oauth_verifier):
|
def get_authorized_tokens(self, oauth_verifier):
|
||||||
"""Returns authorized tokens after they go through the auth_url phase.
|
"""Returns authorized tokens after they go through the auth_url phase.
|
||||||
"""
|
"""
|
||||||
response = self.client.get(self.access_token_url, params={'oauth_verifier': oauth_verifier})
|
response = self.client.get(self.access_token_url, params={'oauth_verifier': oauth_verifier}, verify=self.ssl_verify )
|
||||||
authorized_tokens = dict(parse_qsl(response.content))
|
authorized_tokens = dict(parse_qsl(response.content))
|
||||||
if not authorized_tokens:
|
if not authorized_tokens:
|
||||||
raise TwythonError('Unable to decode authorized tokens.')
|
raise TwythonError('Unable to decode authorized tokens.')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue