From daa5b718f4f0d0ad4715b5188726259b943633b5 Mon Sep 17 00:00:00 2001 From: Eric van Zanten Date: Thu, 6 Jun 2013 13:25:31 -0500 Subject: [PATCH 1/5] Added support for passing access_token_params into an OAuth 1 request. --- flask_oauth.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/flask_oauth.py b/flask_oauth.py index b21105a..682c3a7 100644 --- a/flask_oauth.py +++ b/flask_oauth.py @@ -370,10 +370,12 @@ def handle_oauth1_response(self): function. """ client = self.make_client() - resp, content = client.request('%s?oauth_verifier=%s' % ( - self.expand_url(self.access_token_url), - request.args['oauth_verifier'] - ), self.access_token_method) + remote_args = { + 'oauth_verifier': request.args['oauth_verifier'] + } + remote_args.update(self.access_token_params) + url = add_query(self.expand_url(self.access_token_url), remote_args) + resp, content = client.request(url, self.access_token_method) data = parse_response(resp, content) if not self.status_okay(resp): raise OAuthException('Invalid response from ' + self.name, From 66e1b1395d422c767ec649ad611503de68675a23 Mon Sep 17 00:00:00 2001 From: Eric van Zanten Date: Mon, 10 Jun 2013 09:59:10 -0500 Subject: [PATCH 2/5] Attempting to add ability to include other SSL certs --- flask_oauth.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/flask_oauth.py b/flask_oauth.py index 682c3a7..2a4bb9a 100644 --- a/flask_oauth.py +++ b/flask_oauth.py @@ -178,7 +178,8 @@ def __init__(self, oauth, name, base_url, consumer_key, consumer_secret, request_token_params=None, access_token_params=None, - access_token_method='GET'): + access_token_method='GET', + additional_certs=None): self.oauth = oauth #: the `base_url` all URLs are joined with. self.base_url = base_url @@ -195,6 +196,8 @@ def __init__(self, oauth, name, base_url, self._consumer = oauth2.Consumer(self.consumer_key, self.consumer_secret) self._client = OAuthClient(self._consumer) + if additional_certs: + self._client.ca_certs = additional_certs def status_okay(self, resp): """Given request data, checks if the status is okay.""" From b923b9ff9979ed169083ee115e489d44e96c0c4c Mon Sep 17 00:00:00 2001 From: Eric van Zanten Date: Mon, 10 Jun 2013 10:29:15 -0500 Subject: [PATCH 3/5] Adding ca_certs for make_client method --- flask_oauth.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flask_oauth.py b/flask_oauth.py index 2a4bb9a..64c2d54 100644 --- a/flask_oauth.py +++ b/flask_oauth.py @@ -193,6 +193,7 @@ def __init__(self, oauth, name, base_url, self.request_token_params = request_token_params or {} self.access_token_params = access_token_params or {} self.access_token_method = access_token_method + self.additional_certs = additional_certs self._consumer = oauth2.Consumer(self.consumer_key, self.consumer_secret) self._client = OAuthClient(self._consumer) @@ -239,7 +240,10 @@ def make_client(self, token=None): Usually you don't have to do that but use the :meth:`request` method instead. """ - return oauth2.Client(self._consumer, self.get_request_token(token)) + client = oauth2.Client(self._consumer, self.get_request_token(token)) + if self.additional_certs: + client.ca_certs = self.additional_certs + return client def request(self, url, data="", headers=None, format='urlencoded', method='GET', content_type=None, token=None): From 0a6bd5b747461b2e776fe42590485ad33365a1b1 Mon Sep 17 00:00:00 2001 From: Eric van Zanten Date: Mon, 10 Jun 2013 10:43:41 -0500 Subject: [PATCH 4/5] Added a bit of documentation --- flask_oauth.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flask_oauth.py b/flask_oauth.py index 64c2d54..d84c7eb 100644 --- a/flask_oauth.py +++ b/flask_oauth.py @@ -170,6 +170,8 @@ class OAuthRemoteApp(object): :param access_token_method: the HTTP method that should be used for the access_token_url. Defaults to ``'GET'``. + :param additional_certs: path to a ``pem`` file containing additional SSL + certificates to use for ``HTTPS`` connections. """ def __init__(self, oauth, name, base_url, From 868ac555a8d27d32cfab6c2dcfbfb0cd87de0189 Mon Sep 17 00:00:00 2001 From: Eric van Zanten Date: Mon, 10 Jun 2013 10:56:35 -0500 Subject: [PATCH 5/5] Revert "Added support for passing access_token_params into an OAuth 1 request." This reverts commit daa5b718f4f0d0ad4715b5188726259b943633b5. --- flask_oauth.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/flask_oauth.py b/flask_oauth.py index d84c7eb..d4f96f1 100644 --- a/flask_oauth.py +++ b/flask_oauth.py @@ -379,12 +379,10 @@ def handle_oauth1_response(self): function. """ client = self.make_client() - remote_args = { - 'oauth_verifier': request.args['oauth_verifier'] - } - remote_args.update(self.access_token_params) - url = add_query(self.expand_url(self.access_token_url), remote_args) - resp, content = client.request(url, self.access_token_method) + resp, content = client.request('%s?oauth_verifier=%s' % ( + self.expand_url(self.access_token_url), + request.args['oauth_verifier'] + ), self.access_token_method) data = parse_response(resp, content) if not self.status_okay(resp): raise OAuthException('Invalid response from ' + self.name,