Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to include additional CA certs for SSL requests #52

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions flask_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -178,7 +180,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
Expand All @@ -192,9 +195,12 @@ 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)
if additional_certs:
self._client.ca_certs = additional_certs

def status_okay(self, resp):
"""Given request data, checks if the status is okay."""
Expand Down Expand Up @@ -236,7 +242,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):
Expand Down