Repository navigation
Description
Summary
xtool auth login in password mode fails with an error that gives no clue what went wrong:
Error: DecodingError.dataCorrupted: Data was corrupted. Debug description: The given data was
not a valid property list.. Underlying error: Error Domain=NSCocoaErrorDomain Code=3840
UserInfo={NSDebugDescription=Encountered unknown tag html on line 1}
Two separate things are going on:
- Apple currently answers the
apptokensoperation with503 Service Temporarily Unavailable
as an HTML page. HTTPClientProtocol.makeRequestnever inspectsresponse.status, so that HTML is passed
straight toPropertyListDecoderand the real status and message are lost.
(2) is the part xtool can fix, and it is why this symptom has been so hard to diagnose — see #232
here and altstoreio/AltStore#1698, which look like the same underlying failure seen through the
same missing check.
Environment
- xtool 1.18.1 (AppImage), Linux x86_64
- Password login mode, free (non-paid) Apple ID
What is actually on the wire
I patched makeRequest to log method/URL/status/content-type. The full login is:
[http] GET .../GsService2/lookup -> 200, 25865 bytes, text/x-xml-plist;charset=UTF-8
[http] POST .../GsService2 -> 200, 1451 bytes, text/x-xml-plist;charset=UTF-8 # init
[http] POST .../GsService2 -> 200, 19261 bytes, text/x-xml-plist;charset=UTF-8 # complete
[http] POST .../GsService2 -> 503, 190 bytes, text/html # apptokens
[http] body: <html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>Apple</center>
</body>
</html>
SRP authentication and 2FA both succeed and are remembered. Only the final
GrandSlamFetchAppTokensOperation fails. listTeams is never reached, so nothing on the
Developer Services side is involved (confirmed by strace: exactly one TCP connection for the
whole login, to gsa.apple.com).
The 503 is invariant
| varied | result |
|---|---|
| network (commercial VPN exit in the US, then a residential European ISP) | 503 |
| Apple ID (two different accounts) | 503 |
| repeated attempts, hours apart | 503, byte-identical responses |
X-MMe-Client-Info / User-Agent / X-Xcode-Version (4 variants, below) |
503 |
Client identity variants tried, all reaching apptokens and all getting 503:
| variant | X-MMe-Client-Info |
|---|---|
| current xtool | <Mac16,1> <Mac OS X;14.3.1;23D60> <com.apple.AuthKit/1 (com.apple.akd/1.0)> |
| modern akd | <Mac16,1> <Mac OS X;15.3.1;24D70> <com.apple.AuthKit/1 (com.apple.akd/1.0)> |
Xcode-style (the open // TODO: in DeviceInfo.swift) |
<Mac16,1> <macOS;15.3.1;24D70> <com.apple.AuthKit/1 (com.apple.dt.Xcode/3594.4.19)> |
| internally consistent legacy | <Mac16,1> <Mac OS X;10.14.6;18G103> <com.apple.AuthKit/1 (com.apple.akd/1.0)> |
Apple does read the client string — lookup returned 25865 / 26772 / 26766 / 21311 bytes and
complete 19261 / 23145 / 23145 / 14229 bytes respectively — it just refuses apptokens
regardless. So the 503 looks Apple-side rather than something xtool is sending wrong.
Note that xtool's current identity is internally inconsistent: the client string says macOS
14.3.1 (Darwin 23.x) while userAgent says CFNetwork/978.0.7 Darwin/18.7.0, which is macOS
10.14. That didn't turn out to matter here, but it may be worth tidying.
Suggested fix
In Sources/XKit/HTTPClientProtocol/HTTPClientProtocol.swift, makeRequest returns the body
without ever looking at the status, and every caller decodes it as a plist. Checking the status
there and throwing an error carrying the URL, status and a truncated body turns this:
Error: DecodingError.dataCorrupted: ... Encountered unknown tag html on line 1
into this:
Error: POST https://gsa.apple.com/grandslam/GsService2 failed: HTTP 503 (content-type: text/html)
<html><head><title>503 Service Temporarily Unavailable</title></head>...
I have this working locally and am happy to open a PR if the approach looks right. The one thing
to decide is the blast radius: makeRequest has six call sites, including the SDK and Apple Music
APK downloads, so it would be worth confirming none of them rely on reading a non-2xx body.
Related: 2FA failures are silently swallowed
While tracing this I hit a second symptom worth recording. GrandSlamTrustedDeviceRequest,
GrandSlamSMSAuthRequest and GrandSlamValidateRequest all use no-op decoders
(static func decode(data: Data) throws {}). Combined with the missing status check, a failed
2FA push request is discarded entirely and xtool goes on to prompt:
Code:
for a code that was never sent. A wrong or rejected code is likewise ignored, and the failure only
surfaces later as failedSecondaryAuth or another decoding error. Checking the status in
makeRequest would fix this case too.
Separately, GrandSlamTwoFactorAuthenticateOperation hardcodes let phoneNumberID = "1" with a
// TODO: parse phone number list from o=complete req?, so SMS 2FA always targets whichever
trusted number Apple indexes as 1, without checking the account's actual list.
Activity
am0k161 commentedon Sep 4, 2026
I'm having the same issue on ubuntu 26.04 today, tested with 1.18 and with 1.17. Before today everything worked fine, now I can't log in in any way.
kabiroberai commentedon Sep 4, 2026
This is indeed still happening; should be fixed by #244
gsa: update user agent to fix auth (#244)
kabiroberai commentedon Sep 4, 2026
Released v1.19.0 to fix this. @am0k161 @Robetronica let me know if you still run into the issue after updating.
Separately, @Robetronica feel free to create a PR to improve error handling in these cases!
Robetronica commentedon Sep 5, 2026
With 1.19.0 login works again, thanks for the fix.
Opened #246 for the error handling side
am0k161 commentedon Sep 5, 2026
works for me as well, that was fast. Thanks.
http: throw on unsuccessful responses (#246)
gsa: disregard keepalive (#247)