Restore basic auth for subscriptions API (#6961)

When POSTing to console.redhat.com, fallback
to using basic auth method if OAUTH via
service accounts fails

Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
Seth Foster
2025-05-30 10:18:07 -04:00
committed by Hao Liu
parent bb6bf33b9e
commit 8896f75f9b

View File

@@ -241,14 +241,23 @@ class Licenser(object):
return [] return []
def get_rhsm_subs(self, host, client_id, client_secret): def get_rhsm_subs(self, host, client_id, client_secret):
client = OIDCClient(client_id, client_secret) try:
subs = client.make_request( client = OIDCClient(client_id, client_secret)
'GET', subs = client.make_request(
host, 'GET',
verify=True, host,
timeout=(31, 31), verify=True,
) timeout=(31, 31),
)
except requests.RequestException:
logger.warning("Failed to connect to console.redhat.com using Service Account credentials. Falling back to basic auth.")
subs = requests.request(
'GET',
host,
auth=(client_id, client_secret),
verify=True,
timeout=(31, 31),
)
subs.raise_for_status() subs.raise_for_status()
subs_formatted = [] subs_formatted = []
for sku in subs.json()['body']: for sku in subs.json()['body']: