Skip to content

Commit

Permalink
Reverted removcal of auth token for API
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmwatson committed Jan 22, 2024
1 parent 40f2eb4 commit a37b9c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pmg/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def load_from_api(
params=None,
pagesize=None,
):
""" Load data from the PMG API.
"""Load data from the PMG API.
:param str resource_name: resource to load (used as the start of the URL), or a full URL
:param int resource_id: resource id (optional), appended to the resource name
Expand All @@ -86,7 +86,7 @@ def load_from_api(
query_str += "/" + str(resource_id)
if not v2:
query_str += "/"

if page:
params["page"] = str(page)
if fields:
Expand All @@ -100,6 +100,10 @@ def load_from_api(

logger.debug("Headers: %s" % headers)

# add auth header
if current_user.is_authenticated:
headers["Authentication-Token"] = current_user.get_auth_token()

try:
response = http.request(
"GET", API_URL + query_str, headers=headers, fields=params
Expand Down Expand Up @@ -135,7 +139,7 @@ def load_from_api(
return out
except urllib3.exceptions.HTTPError as e:
logger.error("Error connecting to backend service: %s" % e, exc_info=e)
flash(u"Error connecting to backend service.", "danger")
flash("Error connecting to backend service.", "danger")
raise e


Expand Down

0 comments on commit a37b9c0

Please sign in to comment.