Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions satellitevu/apis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ def make_request(self, *args, **kwargs):
response = self.client.request(*args, **kwargs)

if response.status == 401:
raise Api401Error("Unauthorized to make this request.")
raise Api401Error(
"Unauthorized to make this request.", response, args, kwargs
)
elif response.status == 403:
raise Api403Error(
(
"Not permitted to perform this action. "
"Please contact Satellite Vu for assistance."
)
),
response,
args,
kwargs,
)

return response
Expand Down
25 changes: 13 additions & 12 deletions satellitevu/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,15 @@ def _auth(self, scopes: Optional[List] = None) -> str:
scopes = []
logger.info("Performing client_credential authentication")
token_url = urljoin(self.auth_url, "oauth/token")
response = self.client.post(
token_url,
headers={"content-type": "application/x-www-form-urlencoded"},
data={
"grant_type": "client_credentials",
"client_id": self.client_id,
"client_secret": self.client_secret,
"audience": self.audience,
"scope": " ".join(scopes),
},
)
headers = {"content-type": "application/x-www-form-urlencoded"}
data = {
"grant_type": "client_credentials",
"client_id": self.client_id,
"client_secret": self.client_secret,
"audience": self.audience,
"scope": " ".join(scopes),
}
response = self.client.post(token_url, headers=headers, data=data)

if response.status != 200:
raise AuthError(
Expand All @@ -94,5 +92,8 @@ def _auth(self, scopes: Optional[List] = None) -> str:
return payload["access_token"]
except Exception:
raise AuthError(
"Unexpected response body for client_credential flow: " + response.text
"Unexpected response body for client_credential flow: " + response.text,
response,
["POST", token_url],
{"headers": headers, "data": data},
)
15 changes: 14 additions & 1 deletion satellitevu/auth/exc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
from satellitevu.http.base import ResponseWrapper


class AuthError(RuntimeError):
pass
def __init__(
self,
message: str,
response: ResponseWrapper | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The | operator for union type isn't available until Python 3.10

request_args: list = [],
request_kwargs: dict = {},
):
super().__init__(message)
self.response = response
self.request_args = request_args
self.request_kwargs = request_kwargs


class Api401Error(AuthError):
Expand Down
Loading