#!/usr/bin/env python3
"""Print the FULL enum error (Apollo often appends 'Did you mean ...')."""
import json, urllib.request, urllib.error
def read_key(k):
    for line in open("/home/claude/.config/amd-agent/credentials.env"):
        if line.startswith(k + "="): return line[len(k) + 1:].rstrip("\n")
    return ""
USER = read_key("CUROGRAM_AGENT_USERNAME")
EP = "https://authentication.curogram.com/graphql"
LOGIN = ("mutation Login($email: Email!, $password: String!, $source: LoginPage!) {"
         " login(email: $email, password: $password, source: $source) {"
         " ... on MfaListSchema { mfa { title send id } } ... on ProviderTokenSchema { accountId } } }")
body = json.dumps({"operationName": "Login", "query": LOGIN,
    "variables": {"email": USER, "password": "x", "source": "PROVIDER_X_INVALID"}}).encode()
req = urllib.request.Request(EP, data=body, method="POST", headers={
    "Content-Type": "application/json", "Accept": "application/json",
    "X-Curogram-Frontend": "web"})
try:
    with urllib.request.urlopen(req, timeout=20) as r:
        print(r.read().decode("utf-8"))
except urllib.error.HTTPError as e:
    print(e.read().decode("utf-8", "replace"))
