working
This commit is contained in:
44
FitnessSync/inspect_db_tokens.py
Normal file
44
FitnessSync/inspect_db_tokens.py
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
from sqlalchemy import create_engine, text
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
# Add backend directory to path so we can import models if needed,
|
||||
# but for raw inspection we'll use raw SQL
|
||||
sys.path.append('/app/backend')
|
||||
os.chdir('/app/backend')
|
||||
|
||||
from src.config import get_settings
|
||||
|
||||
settings = get_settings()
|
||||
engine = create_engine(settings.DATABASE_URL)
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
def inspect_tokens():
|
||||
db = SessionLocal()
|
||||
try:
|
||||
result = db.execute(text("SELECT token_type, garth_oauth1_token, garth_oauth2_token, updated_at FROM api_tokens WHERE token_type='garmin'"))
|
||||
row = result.fetchone()
|
||||
|
||||
if not row:
|
||||
print("No Garmin token record found.")
|
||||
return
|
||||
|
||||
print(f"Token Type: {row[0]}")
|
||||
print(f"Updated At: {row[3]}")
|
||||
print("-" * 40)
|
||||
print("OAuth1 Token Raw:")
|
||||
print(row[1])
|
||||
print("-" * 40)
|
||||
print("OAuth2 Token Raw:")
|
||||
print(row[2])
|
||||
print("-" * 40)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error inspecting tokens: {e}")
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
inspect_tokens()
|
||||
Reference in New Issue
Block a user