Skip to content

Commit

Permalink
[google auth] update better logging in authenticate_oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
naisanzaa committed Nov 27, 2024
1 parent 3019e71 commit e020a91
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions automon/integrations/google/auth/client.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import automon
import warnings
import functools
import googleapiclient.http
import googleapiclient.discovery
import google.auth.transport.requests

from automon import log

from .config import GoogleAuthConfig

logger = log.logging.getLogger(__name__)
logger.setLevel(log.DEBUG)
logger = automon.log.logging.getLogger(__name__)
logger.setLevel(automon.log.DEBUG)


class GoogleAuthClient(object):
Expand Down Expand Up @@ -70,14 +70,15 @@ def authenticate_oauth(self) -> bool:
if hasattr(creds, 'refresh_token'):
try:
creds.refresh(google.auth.transport.requests.Request())
logger.info(f'token refresh success')
logger.info(f'{self.authenticate_oauth.__name__} :: token refresh :: {getattr(creds, 'refresh_token')}')
logger.info(f'{self.authenticate_oauth.__name__} :: token refresh :: done')
return True
except Exception as e:
logger.error(msg=f'token refresh failed: {e}')
except Exception as error:
logger.error(msg=f'{self.authenticate_oauth.__name__} :: error :: token refresh failed: {error}')

else:
# TODO: add google flow() authentication here
logger.info(f'flow login success')
warnings.warn(f'TODO: add google flow() authentication')
logger.info(f'{self.authenticate_oauth.__name__} :: done')
return True

return False
Expand Down

0 comments on commit e020a91

Please sign in to comment.