Add debug logging to google_workspace tools
This commit is contained in:
@@ -23,11 +23,15 @@ def _secrets():
|
|||||||
|
|
||||||
def _get_creds(actor_id: str) -> Credentials:
|
def _get_creds(actor_id: str) -> Credentials:
|
||||||
secret_name = 'agent-claw/google-credentials/' + actor_id.replace(':', '-')
|
secret_name = 'agent-claw/google-credentials/' + actor_id.replace(':', '-')
|
||||||
|
print(f'[google] fetching creds for actor={actor_id} secret={secret_name}')
|
||||||
resp = _secrets().get_secret_value(SecretId=secret_name)
|
resp = _secrets().get_secret_value(SecretId=secret_name)
|
||||||
|
print(f'[google] got credential secret')
|
||||||
data = json.loads(resp['SecretString'])
|
data = json.loads(resp['SecretString'])
|
||||||
|
|
||||||
# Load OAuth client info
|
# Load OAuth client info
|
||||||
|
print('[google] fetching oauth client secret')
|
||||||
client_resp = _secrets().get_secret_value(SecretId='agent-claw/google-oauth-client')
|
client_resp = _secrets().get_secret_value(SecretId='agent-claw/google-oauth-client')
|
||||||
|
print('[google] got oauth client secret')
|
||||||
client = json.loads(client_resp['SecretString'])
|
client = json.loads(client_resp['SecretString'])
|
||||||
|
|
||||||
creds = Credentials(
|
creds = Credentials(
|
||||||
@@ -38,9 +42,12 @@ def _get_creds(actor_id: str) -> Credentials:
|
|||||||
client_secret=client.get('client_secret'),
|
client_secret=client.get('client_secret'),
|
||||||
scopes=data.get('scopes'),
|
scopes=data.get('scopes'),
|
||||||
)
|
)
|
||||||
|
print(f'[google] creds created expired={creds.expired}')
|
||||||
|
|
||||||
if creds.expired and creds.refresh_token:
|
if creds.expired and creds.refresh_token:
|
||||||
|
print('[google] refreshing token')
|
||||||
creds.refresh(Request())
|
creds.refresh(Request())
|
||||||
|
print('[google] token refreshed')
|
||||||
# Persist refreshed token
|
# Persist refreshed token
|
||||||
data['token'] = creds.token
|
data['token'] = creds.token
|
||||||
_secrets().put_secret_value(SecretId=secret_name, SecretString=json.dumps(data))
|
_secrets().put_secret_value(SecretId=secret_name, SecretString=json.dumps(data))
|
||||||
|
|||||||
Reference in New Issue
Block a user