Skip to content

Commit cc4290c

Browse files
committed
only get service token once
1 parent f64ff1a commit cc4290c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

htsget_server/beacon_operations.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,12 @@ def full_beacon_search(search_json, headers=None):
418418

419419
# if the request granularity was "record", check to see that the user is actually authorized to see any programs:
420420
response['beaconHandovers'] = []
421+
headers = {
422+
"X-Service-Token": create_service_token()
423+
}
424+
421425
for drs_obj_id in variants_by_file.keys():
422426
# look for experiments and programs for all drs objects, even if user is not authorized
423-
headers = {
424-
"X-Service-Token": create_service_token()
425-
}
426427
resp = requests.get(url=f"{os.getenv("DRS_URL")}/ga4gh/drs/v1/objects/{drs_obj_id}", headers=headers)
427428
if resp.status_code == 200:
428429
drs_obj = resp.json()

htsget_server/variants.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def parse_vcf_file(drs_object_id, reference_name=None, start=None, end=None, hea
7373
if 'contig' in headers:
7474
variants_by_file['contig'] = headers.pop('contig')
7575
experiment_dict = {}
76+
req_headers = {
77+
"X-Service-Token": create_service_token()
78+
}
7679
for r in records:
7780
experiments = []
7881
for vcf_sample in r.samples:
@@ -81,10 +84,7 @@ def parse_vcf_file(drs_object_id, reference_name=None, start=None, end=None, hea
8184
experiment_id = analysis_obj['experiments'][vcf_sample]
8285
if experiment_id not in experiment_dict:
8386
experiment_id = analysis_obj['experiments'][vcf_sample]
84-
headers = {
85-
"X-Service-Token": create_service_token()
86-
}
87-
response = requests.get(url=f"{os.getenv("DRS_URL")}/ga4gh/drs/v1/objects/{experiment_id}", headers=headers)
87+
response = requests.get(url=f"{os.getenv("DRS_URL")}/ga4gh/drs/v1/objects/{experiment_id}", headers=req_headers)
8888
experiment_obj = None
8989
if response.status_code == 200:
9090
experiment_obj = response.json()

0 commit comments

Comments
 (0)