From 81ad74c90b37295f973ba50f0c0392172397419a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Tue, 22 Oct 2024 20:22:24 +0200 Subject: [PATCH] feature/Enable Logging for oauthlib --- apimanager/obp/oauth.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apimanager/obp/oauth.py b/apimanager/obp/oauth.py index 3d553a9..186dffa 100644 --- a/apimanager/obp/oauth.py +++ b/apimanager/obp/oauth.py @@ -13,9 +13,15 @@ from requests_oauthlib.oauth1_session import TokenRequestDenied from .authenticator import Authenticator, AuthenticatorError +# Set up logging +LOGGER = logging.getLogger("requests_oauthlib") +LOGGER.setLevel(logging.DEBUG) # Enable detailed logging for requests-oauthlib -LOGGER = logging.getLogger(__name__) +# Enable logging for oauthlib to capture signature creation +logging.getLogger("oauthlib").setLevel(logging.DEBUG) +# Optionally, format logging output +logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s') class OAuthAuthenticator(Authenticator): """Implements an OAuth authenticator to the API""" @@ -35,6 +41,7 @@ class OAuthAuthenticator(Authenticator): ) try: url = settings.API_HOST + settings.OAUTH_TOKEN_PATH + # Fetch the request token, logging the signature details response = session.fetch_request_token(url, verify=settings.VERIFY) except (ValueError, TokenRequestDenied, ConnectionError) as err: raise AuthenticatorError(err)