Hi, I have a question about AnkiWeb authentication for headless environments.
I am trying to run Anki in a headless environment (no GUI), such as in a Docker container.
However, I found that the recent versions of Anki (24.11 and 25.x) no longer allow add-ons or Python scripts to call sync_login() with email and password. The Rust backend rejects additional parameters, and it looks like the previous method of obtaining an hkey programmatically is no longer available.
This means that without opening the GUI login dialog, the user cannot complete the “Account Required” step, because the required login credentials are only stored after GUI-based authentication.
My questions are:
Is there any supported or documented way to authenticate to AnkiWeb without using the GUI?
For headless environments, is the recommended approach basically to use a virtual display (Xvfb) and automate the GUI login manually?
Is there any alternative for setting the hkey or session information from a script?
If GUI-based login is the only supported authentication method now, I’d like to confirm that before building an automated Xvfb workflow.
Thanks for your help!
Thank you very much for your previous response! Using your suggestion, I was able to successfully set the sync endpoint and perform sync_login() in an add-on, and the hkey and username are saved correctly. This allowed the basic login flow to work in a headless environment—so your guidance was extremely helpful.
However, I still encounter a problem: when the collection has conflicts with the remote server, Anki shows the “conflicting collection” dialog, asking whether to upload the local collection or download from the server. This dialog is modal and blocks the sync process.
My questions:
Is there any supported way to suppress this conflict dialog programmatically?
Can a script or add-on automatically choose “upload local collection” (or “download from server”) without showing the dialog?
Or is this dialog intentionally unskippable, so headless automation must rely on GUI simulation (e.g., pyautogui or Xvfb)?
In short, I want to fully automate sync in a headless setup, including resolving conflicts automatically, if possible. Is there any official or documented method for this?
Thanks again for your guidance—it has been very helpful so far!