Skip to content

Commit cc968e3

Browse files
authored
Merge pull request #245 from DataShades/support_apitoken_header_name
Fix: Support CKAN 2.11.x Config apitoken_header_name - default to 'Authorization'
2 parents 79f9fdf + bc7d701 commit cc968e3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ckanext/xloader/jobs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
# Retries can only occur in cases where the datastore entry exists,
5353
# so use the standard timeout
5454
RETRIED_JOB_TIMEOUT = config.get('ckanext.xloader.job_timeout', '3600')
55+
APITOKEN_HEADER_NAME = config.get('apitoken_header_name', 'Authorization')
5556

5657

5758
# input = {
@@ -316,7 +317,7 @@ def _download_resource_data(resource, data, api_key, logger):
316317
if resource.get('url_type') == 'upload':
317318
# If this is an uploaded file to CKAN, authenticate the request,
318319
# otherwise we won't get file from private resources
319-
headers['Authorization'] = api_key
320+
headers[APITOKEN_HEADER_NAME] = api_key
320321

321322
# Add a constantly changing parameter to bypass URL caching.
322323
# If we're running XLoader, then either the resource has
@@ -462,7 +463,7 @@ def callback_xloader_hook(result_url, api_key, job_dict):
462463
if ':' in api_key:
463464
header, key = api_key.split(':')
464465
else:
465-
header, key = 'Authorization', api_key
466+
header, key = APITOKEN_HEADER_NAME, api_key
466467
headers[header] = key
467468

468469
try:

0 commit comments

Comments
 (0)