Repository navigation
Description
What is the problem you are having with rclone?
rclone config create against the iclouddrive backend reaches the 2FA prompt but Apple never pushes a verification code to any trusted device. The flow appears to succeed (returns {State:2fa_do Option:config_2fa …}) but no code is ever sent, so the user has no way to complete the bootstrap.
There are actually two stacked bugs in the current SRP flow — both tied to rclone's iclouddrive state machine not matching Apple's modern signin/complete → 409 hsa2 response semantics:
Bug 1 — Missing /verify/trusteddevice trigger
After POST /appleauth/auth/signin/complete returns HTTP/1.1 409 {"authType":"hsa2"}, Apple's web sign-in flow requires the client to issue GET /appleauth/auth/verify/trusteddevice to request that a verification code be pushed to a trusted device. rclone currently does not make that call — Session.SignIn() in backend/iclouddrive/api/session.go returns immediately after authSRPComplete, and iclouddrive.go case "": goes straight to fs.ConfigInput("2fa_do", …) without ever telling Apple to send a code.
I verified this with --log-level=DEBUG --dump=headers,bodies:
POST /appleauth/auth/signin/complete?isRememberMeEnabled=true HTTP/1.1
→ HTTP/1.1 409
Location: /auth
X-Apple-Twosv-Trust-Eligible: <…>
X-Apple-Session-Token: <…>
{"authType":"hsa2"}
icloud: SRP sign in requires 2FA
config out: out=&{State:2fa_do Option: OAuth:<nil> Error: Result:}, err=<nil>
No further HTTP call is issued before rclone exits. Apple never pushes a code.
Method sniffing via OPTIONS/Allow headers shows Apple's /verify/trusteddevice endpoint responds:
PUT→405withAllow: GET, POST, OPTIONSPOST→500withAllow: GET(accepts method but rejects the call in context)GET→ 200, pushes a code
So the correct call is GET /appleauth/auth/verify/trusteddevice with the standard SRP auth headers (scnt, X-Apple-Id-Session-Id, X-Apple-Session-Token, etc.) already held by the Session.
Bug 2 — Session lost between state "" and state 2fa_do
Even if Bug 1 is fixed, the current iclouddrive.go state machine cannot actually complete verification, because Apple's SRP codes are session-scoped (bound to the scnt/session-id pair the code was issued against). The current code:
case "":
icloud, err := api.New(...)
icloud.Authenticate(ctx)
m.Set(configCookies, icloud.Session.GetCookieString()) // empty — s.Cookies isn't populated by SignIn
if icloud.Session.Requires2FA() {
return fs.ConfigInput("2fa_do", …)
}
case "2fa_do":
icloud, err := api.New(...)
icloud.SignIn(ctx) // ← fresh SRP session, NEW scnt/session-id
icloud.Session.Validate2FACode(ctx, code) // ← Apple rejects: code tied to previous sessionSession.GetCookieString() returns an empty string after SignIn() because s.Cookies is only populated by AuthWithToken() (via /accountLogin), which only runs after 2FA validation. So rclone.conf ends up with cookies = (empty), state "2fa_do" has nothing to rehydrate from, and the fresh SignIn() creates a brand-new Apple session whose scnt/session-id doesn't know about the code Apple sent earlier. That made both bugs invisible in testing for plaintext-auth-era flows, where codes used to be account-scoped.
Reproduction
-
Create an iclouddrive remote interactively or via:
export RCLONE_CONFIG_TEST_PASSWORD=$(rclone obscure - <<< '<real Apple ID password>') rclone config create test iclouddrive --non-interactive \ [email protected] \ --log-level=DEBUG --dump=headers,bodies -
Observe the SRP flow terminates after
signin/complete's409 hsa2response; noGET /verify/trusteddeviceis made; no push arrives on any trusted device. -
(Even if a code is obtained out-of-band) supplying the code via
--continue --state=2fa_do --result=<code>fails because the fresh SRP session doesn't match the code.
Tested against [email protected] (hsa2, ADP off, "Access iCloud Data on the Web" on, trusted devices available).
Proposed fix
Full patch (134 lines, 2 files): https://gist.github.com/GilbertoLoacker/68334930a490e17c94586744b85f2135
Summary:
- Add
Session.RequestSecurityCode(ctx)that issuesGET /verify/trusteddevicewiths.GetAuthHeaders()andContentLength: 0. - Call it from
iclouddrive.gocase ""immediately after detectingRequires2FA(), before returning the 2FA prompt. - Add
Session.SaveToBlob()/LoadFromBlob()(base64 json) to serialize the full session state (SessionToken,Scnt,SessionID,AuthAttributes,TrustToken,Cookies,AccountInfo,FrameID,ClientID) into the config state string the state machine carries across invocations. case "": encode the session blob into the state token —fs.ConfigInput("2fa_do:"+blob, …).case "2fa_do": split the state on the first:, callSession.LoadFromBlob()on a freshapi.New()instance (sosrv *rest.Clientis initialized byNewSession()), then callValidate2FACode(ctx, code)directly — without a secondSignIn(). This makes the code submission happen on the same SRP session Apple issued the code against.
With this patch the full flow completes end-to-end:
POST /signin/init → 200
POST /signin/complete → 409 hsa2
GET /verify/trusteddevice → 200 ← push arrives on trusted device
POST /verify/trusteddevice/securitycode → 200 (on original session)
GET /2sv/trust → 200
POST /accountLogin → 200
Happy to open a PR if the approach looks reasonable. I went with embedding the session in the state token (rather than writing it to rclone.conf) because the cookies/scnt are short-lived and shouldn't live in the on-disk config, but I'm open to the other approach if maintainers prefer it.
What is your rclone version (output from 'rclone version')
rclone v1.74.0-beta.9591.d58ce7b1b
- os/version: darwin 26.4 (64 bit)
- os/kernel: 25.4.0 (arm64)
- os/type: darwin
- os/arch: arm64 (ARMv8 compatible)
- go/version: go1.26.2
- go/linking: static
- go/tags: none
Which OS you are using and how many bits
macOS 26.4 (Tahoe), arm64
Which cloud storage system are you using?
iCloud Drive (iclouddrive backend)
The command you were trying to run
rclone config create test iclouddrive --non-interactive \
[email protected] \
--log-level=DEBUG --dump=headers,bodies
(with RCLONE_CONFIG_TEST_PASSWORD set to an rclone obscured Apple ID password)
The rclone config contents with secrets removed
[test]
type = iclouddrive
apple_id = [email protected]
cookies =
(cookies is written empty because s.Cookies is never populated in the SRP flow — see Bug 2 above.)
A log from the command with the -vv flag
Full redacted trace available; key excerpt showing the flow stops at signin/complete with no follow-up call:
DEBUG : POST /appleauth/auth/signin/complete?isRememberMeEnabled=true HTTP/1.1
DEBUG : HTTP/1.1 409
Location: /auth
{"authType":"hsa2"}
DEBUG : icloud: SRP sign in requires 2FA
DEBUG : Saving config "cookies" in section "test" of the config file
DEBUG : test: config out: out=&{State:2fa_do Option: OAuth:<nil> Error: Result:}, err=<nil>
DEBUG : rclone: Version "v1.74.0-beta.9591.d58ce7b1b" finishing
(No GET /verify/trusteddevice between signin/complete and the config out line.)
Activity
braiscouce commentedon Apr 9, 2026
Hi,
In the PR #9234 there are some fixes related to 2FA trigger when the trusted device is iOS 26.4. Maybe that fixes your issue.
fdoyon commentedon Apr 15, 2026
Hi, I got it to work with the latest git version bf55d5e
It failed with version 1.73.2 shipped from my manjaro package manager :
ncw commentedon Apr 15, 2026
@fdoyon this is due to be shipped in v1.74 in a week or two.
@GilbertoLoacker since the fix for this is already merged I'm going to close this isse.
Try the latest beta
ItsAperoTime commentedon Apr 15, 2026
Hello,
I have the issue with the docker image tag beta (which include rclone v1.74.0-beta.9623.bf55d5e6d).
I use the tool for first time and try to config iCloud Drive. The lastest image dont show the 2FA ask, the beta tag I have the 2FA asked but never show on one of my apple devices.
So I am not sure if the issue is resolved ?
I hope I don't bother to text here I drive from issues to issues to find help
andrew-schulman commentedon Apr 23, 2026
I also tried beta release 1.74.0.beta.9643.8688785a7. It prompts for the config_2fa value, but as @ItsAperoTime said, none of my Apple devices prompted me with the code. So not working yet.
ncw commentedon Apr 23, 2026
@mikegillan since you did 35e4f60 which implemented the SRP flow I thought you might have an idea about this?
ncw commentedon Apr 23, 2026
I'm going to close this issue in favor of #9359 which is more focussed.
punya10 commentedon Jul 25, 2026
I hit this on v1.74.4 and latest master (every 2FA attempt failing with
HTTP error 409while the response body said\"valid\" : true, on both the trusted-device and SMS paths) and traced it with--dump headers: Apple's idmsa now returns HTTP 409 on a successful code validation. The 409 response actually carries a freshX-Apple-Session-Token,scntandX-Apple-Auth-Attributes— i.e. validation succeeded, but rclone treats the 409 as an error and aborts before the trust step, discarding the token it was just issued.Fix in #9660: treat a 409 that carries
X-Apple-Session-Tokenas success and continue toTrustSession. Verified working against a live account (config completes;lsd/lsjson -R/copyall work). Until it's merged, building master with that one-file patch is a usable workaround.🤖 Generated with Claude Code
docs(cloud): iCloud rclone BLOQUÉ upstream (bug 2FA #9324) — patch in…
fix(cloud): patch local rclone iclouddrive — accepte le 409 'code val…