Files
FitTrack2/FitnessSync/backend/src/models/api_token.py
2025-12-24 18:12:11 -08:00

24 lines
1.2 KiB
Python

from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.sql import func
from ..models import Base
import json
class APIToken(Base):
__tablename__ = "api_tokens"
id = Column(Integer, primary_key=True, index=True)
token_type = Column(String, nullable=False) # 'fitbit' or 'garmin'
access_token = Column(String, nullable=True) # This should be encrypted in production
refresh_token = Column(String, nullable=True) # This should be encrypted in production
expires_at = Column(DateTime, nullable=True)
scopes = Column(String, nullable=True)
garth_oauth1_token = Column(String, nullable=True) # OAuth1 token for garmin (JSON)
garth_oauth2_token = Column(String, nullable=True) # OAuth2 token for garmin (JSON)
# MFA session fields for garmin
mfa_session_id = Column(String, nullable=True)
mfa_resume_data = Column(String, nullable=True) # JSON blob
mfa_state = Column(String, nullable=True) # State for garth.resume_login
mfa_expires_at = Column(DateTime, nullable=True)
last_used = Column(DateTime, nullable=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())