06/03 Optimize app

This commit is contained in:
2026-06-03 16:06:30 -04:00
parent 4af31a611e
commit ec1c0fc7c1
14 changed files with 447 additions and 12 deletions
+5 -2
View File
@@ -144,8 +144,11 @@ def refresh_tokens(connection):
def _apply_token_data(connection, data):
"""Write token fields from token response onto connection model."""
connection.access_token = data['access_token']
connection.refresh_token = data.get('refresh_token', connection.refresh_token)
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)
expires_in = int(data.get('expires_in', 1800))
connection.token_expires_at = datetime.utcnow() + timedelta(seconds=expires_in - 60)