security(kms+refresh): optional KMS envelope keys + token refresh flow for Google

This commit is contained in:
TLimoges33
2025-08-28 17:14:49 +00:00
parent 8d62ac0017
commit ed71629f88
4 changed files with 117 additions and 1 deletions
+5
View File
@@ -56,6 +56,11 @@ def google_events(integration_id: int):
token = db.query(models.OAuthToken).filter_by(integration_id=integration_id).order_by(models.OAuthToken.id.desc()).first()
if not token or not token.access_token:
raise HTTPException(status_code=404, detail='no token found for integration')
# Try to refresh token if needed (refresh flow is in oauth module)
from .oauth import refresh_google_token_if_needed
refreshed = refresh_google_token_if_needed(token)
if refreshed:
token = refreshed
from .crypto import decrypt_text
decrypted_access = decrypt_text(token.access_token)