Skip to content

Fix and integrate with anisette mac backend - #279

Open
sacca97 wants to merge 2 commits into
malmeloo:mainfrom
sacca97:main
Open

sacca97 wants to merge 2 commits into
malmeloo:mainfrom
sacca97:main

Conversation

@sacca97

@sacca97 sacca97 commented Oct 19, 2026 •

Copy link
Copy Markdown

Some changes required by the new anisette backend system to be coherent when sending requests to apple servers + fixes of issues encountered along the way.

Some tests might be removed eventually.

Fixes #278

@rabea98

rabea98 commented Oct 20, 2026

Copy link
Copy Markdown

Thanks for working on this! Quick question about the macOS ADI backend: macos.py pins adid to SHA-256 4b6b320f08edcf5d65ed1141399b76a8d9323fee2045c577c5d2f30f35a5dae1, but I can't find which macOS version that /usr/libexec/adid comes from. Which exact macOS 26 build produced it (e.g. 26.6.2 / 25G83)? I'm on Windows with no Mac, so I'd need to pull the file from a matching build. Thanks!

@sacca97

sacca97 commented Oct 20, 2026 •

Copy link
Copy Markdown
Author

@rabea98 it should be the latest available 26.X image, and then once you get the adi you have to take out the x86 part because is a fat one. I can check later tonight or tomorrow morning before making you download the wrong one.

ideally anything should work tho. I also tried another earlier MacOS i can't remember. I guess from 26.X you can pick any random one

@sacca97

sacca97 commented Oct 21, 2026

Copy link
Copy Markdown
Author

@rabea98 macOS 26.7.1 (25G241) x86_64 adid

@GunayAnach

Copy link
Copy Markdown

Tested the proposed local macOS ADI backend with Home Assistant running in a Linux Mint x86_64 container (Python 3.14).

Build and setup

Built the Python wheels in the HA environment from these commits:
FindMy.py: f2d24c8
Anisette.py: 627c9c663062bd872182b653113759c9d66b7e13
macOS-ADI-emulator: d4d2a832baf47d1cf43d989879950ac2aec45f47
Used the separately supplied CoreADI.x86_64 binary; its SHA-256 matched the backend’s expected hash: 4b6b320f08edcf5d65ed1141399b76a8d9323fee2045c577c5d2f30f35a5dae1.
Kept packages and binary on HA’s persistent /config mount, configured PYTHONPATH and MACOS_ADI_BINARY, and left the Anisette URL blank to select the local provider.
Results

The emulator booted and the local Anisette provider initialized.
Apple sign-in completed, including 2FA; HA set up the FindMy integration.
The first location fetch reported success, and a tracker reported location.
This was a real HA integration smoke test, not a run of the full upstream test suites. No credentials or tracker private keys were included.

wanderdev0 pushed a commit to wanderdev0/FindMy.py that referenced this pull request Nov 20, 2026
Since 2026-10-12 a password Apple accepts but wants a code for is
answered at the SRP complete step with hsc 409 and no au. au is what
_gsa_authenticate reads to decide that a code is needed, so the sign-in
was taken as finished, the code was never asked for, and the mobileme
delegate login after it failed with status=1 (malmeloo#278,
OpenTagViewer#248).

_normalize_2fa_status fills au in as trustedDeviceSecondaryAuth, which
is how sacca97/os-findmy-e signs in. Same name and placement as
malmeloo#279, so a later sync with upstream is a no-op here.
A 409 that does name au is left as Apple sent it.

OpenTagViewer did this by wrapping _gsa_request on each account at
runtime; with this it can drop that.

The tests run the whole SRP exchange offline against a verifier built
from the same password, so they exercise _gsa_authenticate's own
decision. Without the call, the 409 test fails with AUTHENTICATED.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015MJtmGkNZpfzFGSN1BZ82a
wanderdev0 pushed a commit to wanderdev0/OpenTagViewer that referenced this pull request Nov 21, 2026
The fix belongs in FindMy.py's _gsa_authenticate, where
malmeloo/FindMy.py#279 adds _normalize_2fa_status; the same change is
prepared for parawanderer/FindMy.py. Until the pin moves,
_treatHsc409AsSecondFactor keeps wrapping _gsa_request, but returns
without touching the account when the pinned FindMy.py has the
function. test_the_pinned_findmy_does_not_yet fails on the pin move,
which is the cue to delete the wrapper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015MJtmGkNZpfzFGSN1BZ82a
@xudongzheng

Copy link
Copy Markdown

Very nice work. This combined with malmeloo/Anisette.py#6 works for me on Linux. The old Android-based backend seems to have stopped authenticating recently.

@godric

godric commented Nov 29, 2026 •

Copy link
Copy Markdown

👋 Another working setup: (x86_64, HA 2026.11.3) with this PR (f2d24c8), Anisette.py#6 and the emulator from os-findmy-e@d4d2a83. Sign-in with 2FA works and location reports are fetched again.

FYI, The adid binary can be extracted from Apple's own macOS 26.7.1 (25G241) full installer, still on Apple's CDN (product 142-28081). Its CoreADI.framework/Versions/A/adid, thinned to x86_64, matches the pinned SHA-256 4b6b320f…5dae1. The latest macOS 27 adid does not work with the emulator.

@borrowcheckmate

Copy link
Copy Markdown

Another data point, with one extra fix that was needed here.

Setup: Home Assistant OS with this PR (f2d24c8), Anisette.py#6 (627c9c6) and the emulator from os-findmy-e@d4d2a83, CoreADI matching the pinned SHA-256.

GSA 503 without X-Apple-I-MD-M as an HTTP header

For me every GsService2 request answered HTTP 503 (like #268 / #269), even with this PR. I ruled out the CoreADI build (the pinned 26.7.1 file and a newer 26.x one behave the same), the egress IP, the User-Agent and the TLS stack (Apple's own NSURLSession on a Mac also got 503). Even anisette taken natively from a Mac got 503 through FindMy.py's request.

A request shaped like akd's did work. Bisecting its headers, the only one that matters is X-Apple-I-MD-M: FindMy.py only sends it inside the cpd body, not as a header. Adding it to the headers in _gsa_request fixed it, and sign-in with 2FA and report fetching work since:

         headers = {
             "Content-Type": "text/x-xml-plist",
             "Accept": "*/*",
             "User-Agent": "akd/1.0 CFNetwork/978.0.7 Darwin/18.7.0",
             "X-MMe-Client-Info": self._anisette.client,
+            # Apple's edge answers 503 to Grand Slam requests without the machine ID header.
+            "X-Apple-I-MD-M": cpd["X-Apple-I-MD-M"],
         }

Others here don't hit it, so it may be a staged rollout on Apple's side, but the header is harmless when it isn't required. Could it go into this PR?

Installing in Home Assistant

HA installs integration requirements with uv, which refuses the git+https://… dependency on macos-adi-emulator in Anisette.py#6 ("Failed to resolve dependencies for package anisette"), because it's a URL dependency nested in another package. What worked: depend on macos-adi-emulator==0.1.0 in Anisette's pyproject.toml, and list the emulator as its own requirement in the integration's manifest.json, before Anisette. Publishing the emulator to PyPI would avoid this.

myTselectionPublic pushed a commit to myTselectionPublic/hass-FindMy that referenced this pull request Nov 29, 2026
and [Anisette.py PR malmeloo#6](malmeloo/Anisette.py#6). It emulates
Apple's macOS ADI daemon instead of the Android libraries used by the default
integrated provider.

An example CoreADI.x86_64 can be downloaded from https://sharebin.eu/files/CoreADI.x86_64,  as shared in malmeloo/Anisette.py#6

To be stored in /config/.storage/findmy/CoreADI.x86_64

Under **Advanced options**, enable **Use experimental macOS Anisette backend** and leave **Remote Anisette URL** empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Since 2026-10-12: mobileme returns only mmeAuthToken (no searchPartyToken) — login OK, report fetch 401

6 participants