06/04 Optimize app

This commit is contained in:
2026-06-04 10:48:31 -04:00
parent 3abd073437
commit 8bed900297
6 changed files with 22 additions and 11 deletions
+4 -3
View File
@@ -153,9 +153,10 @@ def _apply_token_data(connection, data):
"""Write token fields from token response onto connection model."""
connection.access_token = data['access_token']
if data.get('refresh_token'):
connection.refresh_token = data['refresh_token']
# Schwab refresh tokens expire 7 days after issue
connection.refresh_token_expires_at = datetime.utcnow() + timedelta(days=7)
connection.refresh_token = data['refresh_token']
# Reset the 7-day expiry window on every successful token exchange so the
# dashboard warning doesn't trigger prematurely when the token isn't rotated.
connection.refresh_token_expires_at = datetime.utcnow() + timedelta(days=7)
expires_in = int(data.get('expires_in', 1800))
connection.token_expires_at = datetime.utcnow() + timedelta(seconds=expires_in - 60)