Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get token for nr_details
Browse files Browse the repository at this point in the history
seeker25 committed Nov 16, 2023
1 parent 84d5f8a commit ca47025
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions auth-api/src/auth_api/services/affiliation.py
Original file line number Diff line number Diff line change
@@ -234,7 +234,7 @@ def create_new_business_affiliation(affiliation_data: AffiliationData, # pylint
entity = EntityService.find_by_business_identifier(business_identifier, skip_auth=True)

# Call the legal-api to verify the NR details
if not (nr_json := Affiliation._get_nr_details(business_identifier, bearer_token)):
if not (nr_json := Affiliation._get_nr_details(business_identifier)):
raise BusinessException(Error.NR_NOT_FOUND, None)

status = nr_json.get('state')
@@ -469,11 +469,13 @@ def _combine_affiliation_details(details):
return [name_request for nr_num, name_request in name_requests.items()] + drafts + businesses

@staticmethod
def _get_nr_details(nr_number: str, token: str):
def _get_nr_details(nr_number: str):
"""Return NR details by calling legal-api."""
nr_api_url = current_app.config.get('NAMEX_API_URL')
get_nr_url = f'{nr_api_url}/requests/{nr_number}'
try:
token = RestService.get_service_account_token(
config_id='ENTITY_SVC_CLIENT_ID', config_secret='ENTITY_SVC_CLIENT_SECRET')
get_nr_response = RestService.get(get_nr_url, token=token, skip_404_logging=True)
except (HTTPError, ServiceUnavailableException) as e:
current_app.logger.info(e)

0 comments on commit ca47025

Please sign in to comment.