diff --git a/CHANGES/1049.bugfix b/CHANGES/1049.bugfix new file mode 100644 index 000000000..e69de29bb diff --git a/pulp-glue/pulp_glue/common/authentication.py b/pulp-glue/pulp_glue/common/authentication.py index 646ee5306..25f9f410a 100644 --- a/pulp-glue/pulp_glue/common/authentication.py +++ b/pulp-glue/pulp_glue/common/authentication.py @@ -25,6 +25,9 @@ def __init__( self.access_token: t.Optional[str] = None self.expire_at: t.Optional[datetime] = None + if not any(client_id, client_secret, token_url): + return None + def __call__(self, request: requests.PreparedRequest) -> requests.PreparedRequest: if self.expire_at is None or self.expire_at < datetime.now(): self.retrieve_token() @@ -78,10 +81,12 @@ def retrieve_token(self) -> None: data = { "client_id": self.client_id, "client_secret": self.client_secret, - "scope": " ".join(self.scopes), "grant_type": "client_credentials", } + if scope := " ".join(self.scopes): + data["scope"] = scope + response: requests.Response = requests.post(self.token_url, data=data) response.raise_for_status()