Icloud connect not working: HTTP error 400

Confirming what other users posted above. The user agent string workaround worked a little while back, but doesn’t work any more. I tried random user agent strings, tried using the exact same user agent string my browser uses to log in to iCloud online without luck.

Workaround

I made a proof of concept authentication script, which uses Puppeteer to pull the needed cookies:

If you want to do it manually, without the script, below are the steps:

  1. Open your web browser
  2. Log in to icloud.com, follow MFA prompts until you get to the dashboard screen that shows your profile, recent files, etc.
  3. Make sure to select "remember device" otherwise your token will only last around 30 minutes.
  4. Open developer tools and have a look at the request to www.icloud.com (or pretty much any other request to the same domain).
  5. Copy the Cookie header (X-APPLE-WEBAUTH-USER="v=1:s=0:d=......)
  6. In the Cookie header you just copied, there is a trust token. X-APPLE-WEBAUTH-HSA-TRUST="..." Copy the part between the double quotes.
  7. Run the command rclone config update [remote] cookies=FULL_COOKIES_HEADER_GOES_HERE trust_token=TRUST_TOKEN_GOES_HERE
  8. Run rclone config reconnect remote:
  9. Test by running rclone config ls remote:

Note:
I tried using the environment variable RCLONE_ICLOUDDRIVE_TRUST_TOKEN and flag --iclouddrive-trust-token but neither worked. Please let me know if there’s a way to use this instead :slight_smile:

1 Like