import requests

url = "http://localhost:8000/auth/token"
data = {
    "username": "test@example.com",
    "password": "password123"
}

try:
    response = requests.post(url, data=data)
    print(f"Login Status: {response.status_code}")
    if response.status_code == 200:
        print("Login successful!")
        token = response.json().get("access_token")
        # Test /users/me
        me_url = "http://localhost:8000/users/me"
        headers = {"Authorization": f"Bearer {token}"}
        me_response = requests.get(me_url, headers=headers)
        print(f"User Profile: {me_response.json()}")
    else:
        print(f"Login failed: {response.text}")
except Exception as e:
    print(f"Error: {e}")
