sources/oauth: fix not all token errors being logged with response
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
e19c4886fe
commit
153bd3aaf1
|
@ -43,7 +43,11 @@ class BaseOAuthClient:
|
||||||
try:
|
try:
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except RequestException as exc:
|
except RequestException as exc:
|
||||||
self.logger.warning("Unable to fetch user profile", exc=exc, body=response.text)
|
self.logger.warning(
|
||||||
|
"Unable to fetch user profile",
|
||||||
|
exc=exc,
|
||||||
|
response=exc.response.text if exc.response else str(exc),
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,11 @@ class OAuthClient(BaseOAuthClient):
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except RequestException as exc:
|
except RequestException as exc:
|
||||||
LOGGER.warning("Unable to fetch access token", exc=exc)
|
LOGGER.warning(
|
||||||
|
"Unable to fetch access token",
|
||||||
|
exc=exc,
|
||||||
|
response=exc.response.text if exc.response else str(exc),
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
return self.parse_raw_token(response.text)
|
return self.parse_raw_token(response.text)
|
||||||
return None
|
return None
|
||||||
|
@ -61,7 +65,9 @@ class OAuthClient(BaseOAuthClient):
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except RequestException as exc:
|
except RequestException as exc:
|
||||||
raise OAuthSourceException from exc
|
raise OAuthSourceException(
|
||||||
|
response=exc.response.text if exc.response else str(exc),
|
||||||
|
) from exc
|
||||||
return response.text
|
return response.text
|
||||||
|
|
||||||
def get_redirect_args(self) -> dict[str, Any]:
|
def get_redirect_args(self) -> dict[str, Any]:
|
||||||
|
|
|
@ -84,7 +84,11 @@ class OAuth2Client(BaseOAuthClient):
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except RequestException as exc:
|
except RequestException as exc:
|
||||||
LOGGER.warning("Unable to fetch access token", exc=exc)
|
LOGGER.warning(
|
||||||
|
"Unable to fetch access token",
|
||||||
|
exc=exc,
|
||||||
|
response=exc.response.text if exc.response else str(exc),
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
|
@ -147,6 +151,10 @@ class UserprofileHeaderAuthClient(OAuth2Client):
|
||||||
try:
|
try:
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except RequestException as exc:
|
except RequestException as exc:
|
||||||
LOGGER.warning("Unable to fetch user profile", exc=exc, body=response.text)
|
LOGGER.warning(
|
||||||
|
"Unable to fetch user profile",
|
||||||
|
exc=exc,
|
||||||
|
response=exc.response.text if exc.response else str(exc),
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
Reference in New Issue