Skip to content

Commit

Permalink
Merge pull request #245 from DataShades/support_apitoken_header_name
Browse files Browse the repository at this point in the history
Fix: Support CKAN 2.11.x Config apitoken_header_name - default to 'Authorization'
  • Loading branch information
duttonw authored Mar 3, 2025
2 parents 79f9fdf + bc7d701 commit cc968e3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ckanext/xloader/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
# Retries can only occur in cases where the datastore entry exists,
# so use the standard timeout
RETRIED_JOB_TIMEOUT = config.get('ckanext.xloader.job_timeout', '3600')
APITOKEN_HEADER_NAME = config.get('apitoken_header_name', 'Authorization')


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

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

try:
Expand Down

0 comments on commit cc968e3

Please sign in to comment.