Skip to content

Commit

Permalink
The params were not being passed changed
Browse files Browse the repository at this point in the history
  • Loading branch information
romanchyla committed Jun 4, 2020
1 parent ab1247d commit 9c32786
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 6 additions & 3 deletions biblib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@ def __init__(self, config):

self.session = requests.Session()

def _sanitize(self, *args, **kwargs):
def _sanitize(self, args, kwargs):
headers = kwargs.get('headers', {})
if 'Authorization' not in headers:
headers['Authorization'] = current_app.config.get('SERVICE_TOKEN', None) or request.headers.get('X-Forwarded-Authorization', request.headers.get('Authorization', None))
if 'timeout' not in kwargs:
kwargs['timeout'] = current_app.config.get('GET_TIMEOUT', 5)
kwargs['headers'] = headers
return (args, kwargs)

def get(self, *args, **kwargs):
self._sanitize(*args, **kwargs)
args, kwargs = self._sanitize(args, kwargs)
return self.session.get(*args, **kwargs)

def post(self, *args, **kwargs):
self._sanitize(*args, **kwargs)
args, kwargs = self._sanitize(args, kwargs)
return self.session.post(*args, **kwargs)

6 changes: 1 addition & 5 deletions biblib/views/library_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ def get_documents_from_library(cls, library_id, service_uid):
current_app.logger.info('Obtaining email of user: {0} [API UID]'
.format(owner.absolute_uid))

headers = {
'Authorization': current_app.config.get('SERVICE_TOKEN', request.headers.get('X-Forwarded-Authorization', request.headers.get('Authorization', '')))
}
response = client().get(
service,
headers=headers
service
)

# For this library get all the people who have permissions
Expand Down

0 comments on commit 9c32786

Please sign in to comment.