From 67153b74236a0e6c0afb19149fecdc1d3d683b66 Mon Sep 17 00:00:00 2001 From: patrickpeinanw <144158754+patrickpeinanw@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:40:33 -0700 Subject: [PATCH] add token into colin-api call (#1419) Co-authored-by: Patrick Wang --- solr-feeder/solr_feeder/services/colin.py | 6 +++++- solr-feeder/solr_feeder/services/search.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/solr-feeder/solr_feeder/services/colin.py b/solr-feeder/solr_feeder/services/colin.py index 8231c2983..e8de6494d 100644 --- a/solr-feeder/solr_feeder/services/colin.py +++ b/solr-feeder/solr_feeder/services/colin.py @@ -51,11 +51,15 @@ def _parse_party(party: dict, legal_type: str): return party -def get_business_info(legal_type: str, identifier: str) -> tuple[dict, dict]: +def get_business_info(legal_type: str, identifier: str, token: str) -> tuple[dict, dict]: """Return the basic business info of the business.""" try: + headers = {'Authorization': 'Bearer ' + token} + res = requests.get(f'{current_app.config["COLIN_API_URL"]}/businesses/{legal_type}/{identifier}', + headers=headers, timeout=current_app.config['COLIN_API_TIMEOUT']) + if res.status_code != HTTPStatus.OK: return None, {'message': res.json(), 'status_code': res.status_code} diff --git a/solr-feeder/solr_feeder/services/search.py b/solr-feeder/solr_feeder/services/search.py index aa0beef93..3c0612c7b 100644 --- a/solr-feeder/solr_feeder/services/search.py +++ b/solr-feeder/solr_feeder/services/search.py @@ -50,7 +50,7 @@ def update_search_cores(identifier: str, legal_type: str): return error # get business data - business, error = get_business_info(legal_type, identifier) + business, error = get_business_info(legal_type, identifier, token) if error: logging.error('Error getting COLIN business data: %s', error) return {'message': error['message']}, HTTPStatus.INTERNAL_SERVER_ERROR