import asyncio import os from monarchmoney import MonarchMoney from dotenv import load_dotenv async def test_token(): load_dotenv(override=True) token = os.getenv("MONARCH_TOKEN") email = os.getenv("MONARCH_EMAIL") password = os.getenv("MONARCH_PASSWORD") if token and token.strip(): # Strip potential prefix if token.startswith("MONARCH_TOKEN="): token = token.replace("MONARCH_TOKEN=", "") print(f"Testing with TOKEN: {token[:10]}...") mm = MonarchMoney(token=token) elif email and password: print(f"Testing with EMAIL: {email}") mm = MonarchMoney() try: await mm.login(email, password) print("✅ Login successful with email/password!") except Exception as e: print(f"❌ Login failed: {e}") return else: print("❌ No credentials found in .env") return try: accounts = await mm.get_accounts() print(f"Success! Found {len(accounts.get('accounts', []))} accounts.") except Exception as e: print(f"Error fetching accounts: {e}") if __name__ == "__main__": asyncio.run(test_token())