#!/usr/bin/env python3
"""Quick authentication status checker."""

import json
from pathlib import Path
from datetime import datetime

def check_auth_status():
    print("🔍 Authentication Status Check")
    print("=" * 40)
    
    # Check Gmail/Calendar
    cos_token = Path.home() / '.clawdbot' / 'skills' / 'gmail' / 'tokens' / 'cos.json'
    if cos_token.exists():
        try:
            token_data = json.loads(cos_token.read_text())
            scopes = token_data.get('scopes', [])
            expiry = token_data.get('expiry', 'Unknown')
            
            print(f"📧 Gmail/Calendar: ✅ Active ({len(scopes)} scopes)")
            print(f"   Expires: {expiry}")
            
            gmail_scopes = [s for s in scopes if 'gmail' in s]
            calendar_scopes = [s for s in scopes if 'calendar' in s]
            print(f"   Gmail scopes: {len(gmail_scopes)}")
            print(f"   Calendar scopes: {len(calendar_scopes)}")
            
        except Exception as e:
            print(f"📧 Gmail/Calendar: ❌ Error reading token - {e}")
    else:
        print("📧 Gmail/Calendar: ❌ No token found")
    
    # Check Notion
    notion_key = Path.home() / '.config' / 'notion' / 'api_key'
    if notion_key.exists():
        key = notion_key.read_text().strip()[:20] + "..."
        print(f"📝 Notion: ✅ API key found ({key})")
    else:
        print("📝 Notion: ❌ No API key found")

if __name__ == "__main__":
    check_auth_status()
