Skip to content

Commit

Permalink
extract error information from APEL token endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfischer2781 committed Jan 22, 2025
1 parent ecd3b28 commit 4c0955e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugins/apel/src/auditor_apel_plugin/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,15 @@ def get_token(config):
except requests.Timeout:
logger.critical("Timeout while getting token")
raise

token = response.json()["token"]

return token
try:
return response.json()["token"]
except KeyError:
if error_message := response.json().get("error", {}).get("message"):
raise RuntimeError(
f"could not get authentication token: {error_message} [{response.status_code} {response.reason}]"
)
response.raise_for_status()
raise


def sign_msg(config, msg):
Expand Down

0 comments on commit 4c0955e

Please sign in to comment.