Skip to content

Commit

Permalink
Add exceptions for missing offline_token and access token error response
Browse files Browse the repository at this point in the history
  • Loading branch information
synkd committed Jul 31, 2024
1 parent ddbf38c commit 94a9f71
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions manifester/manifester.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import string

from dynaconf.utils.boxing import DynaBox
from requests.exceptions import Timeout
from requests.exceptions import RequestException, Timeout

from manifester.helpers import (
fetch_paginated_data,
Expand All @@ -35,8 +35,10 @@ def __init__(
if minimal_init:
if kwargs.get("offline_token") is not None:
self.offline_token = kwargs.get("offline_token")
else:
elif settings.get("offline_token") is not None:
self.offline_token = settings.get("offline_token")
else:
raise KeyError("Offline token not defined.")
self.token_request_url = settings.get("url").get("token_request")
self.allocations_url = settings.get("url").get("allocations")
self._access_token = None
Expand Down Expand Up @@ -113,6 +115,8 @@ def access_token(self):
cmd_args=[f"{self.token_request_url}"],
cmd_kwargs=token_request_data,
).json()
if "error" in token_data:
raise RequestException(f"{token_data['error']}: {token_data['error_description']}")
if self.is_mock:
self._access_token = token_data.access_token
else:
Expand Down

0 comments on commit 94a9f71

Please sign in to comment.