Skip to content

Update Proton Drive app-version header to rclone specific one - #9189

Closed
dlaumen wants to merge 0 commit into
rclone:masterfrom
dlaumen:master
Closed

dlaumen wants to merge 0 commit into
rclone:masterfrom
dlaumen:master

Conversation

@dlaumen

@dlaumen dlaumen commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Hi

I'm an engineer in the Proton Drive team. We would like to ask you to make a minor change in the way you interact with the API.

  1. Change the domain to drive-api.proton.me
    • There are changes planned to the infrastructure so that Drive API endpoints are only available on the drive-api host, this'll ensure your client will keep working for you and users of this client in the future.
    • See Update hosturl to drive-api go-proton-api#1
  2. Change the app-version header
    • We have added support for third-party app-version headers: external-drive-<project>@<semver-version>, e.g. [email protected]
    • The project name must conform to -[a-z_]+
    • The version can be any semver-compliant version number, you can inject your own version numbering if you want
    • This ensures that this client remains functional even if we perform a force-upgrade of one of our official clients, which would prevent a specific app-version from using the API
    • This would also help us with our metrics, as they currently report your client as the official MacOS client, which causes problems for our team when debugging because errors from the official client get mixed in with errors from this project

We would be very grateful if you could adopt these changes, even though we cannot offer more support for third parties at this moment.

@ncw

ncw commented Feb 18, 2026

Copy link
Copy Markdown
Member

Hi @dlaumen , thanks for getting in touch.

We always try to work with the vendors so I don't see any problem with merging this.

You have [email protected] in your identifier string.

Do you want the current version of rclone? This is in fs.Version eg v1.74.0-beta.9474.f8e1d74b9 or v1.73.0 which should be semver compliant (perhaps without the leading v)?

@dlaumen

dlaumen commented Feb 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you for the followup @ncw !

I didn't know how to dynamically get a version number, and for us it's currently mostly important to be able to distinguish official versus 3rd party clients.

I did just double-checked against our parser for this version, but unfortunately that won't work. It's apparently slightly stricter than what semver allows in regards to the pre-release identifiers, we only allow integers. We do support a +build

The regex for the whole version string:

/^(external-drive)+(-[a-z_]+)+@[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-((stable|beta|RC|alpha)(([.-]?\d+)*)?)?([.-]?dev)?(\+.*)?$/i

So this could work: [email protected]+f8e1d74b9 or simply [email protected] or [email protected]. For us it doesn't matter that much how detailed you send a version number.

Am I also correct in assuming this app_version is configurable/overridable by the user?
We currently have some workarounds/exceptions in place on the API for rclone to avoid breaking changes on uploads, but if a user sets a custom app_version and we can no longer detect the request comes from rclone then the upload will fail. We will keep this exception in place for rclone until after the Proton Drive SDK is deemed stable and 3rd parties had a chance to implement it. So it might maybe be better if the user cannot override this and break uploads without knowing/understanding why?

@dlaumen dlaumen closed this Apr 27, 2026
mmornati pushed a commit to mmornati/gphoto2proton that referenced this pull request Jul 31, 2026
Review follow-up: probing the real POST /auth/v4/info endpoint showed
the live server rules differ from the regex published in
rclone/rclone#9189:

- the project name must be a SINGLE section: inner dashes are rejected
  with 2064 "Invalid section name"
  ([email protected] fails live)
- underscores are fine (external-drive-gphoto_proton@... passes)
- digits and a bare semver are accepted live, but we keep the stricter
  published intersection (letters+underscores, explicit -stable
  channel) to be robust against future server-side tightening

protonAppVersion is now [email protected],
verified live: the exact request that failed in the PR description
(400 / Code 2064) now passes.

Also send x-pm-appversion on the hand-rolled photos-api calls in
AlbumAdapter (the header was missing entirely there), correct the
User-Agent comments/tests (the UA format is not actually validated
server-side; the 2064 dash error refers to x-pm-appversion), and add
env-gated live integration tests (auth headers regression + album
create/delete round-trip) that skip without credentials.

Note: full login currently stops at POST /auth/v4 with 422 Code=9001
(CAPTCHA challenge) — Proton anti-abuse risk scoring, unrelated to
these headers; a dummy login gets the expected 2001 instead.
mmornati added a commit to mmornati/gphoto2proton that referenced this pull request Aug 1, 2026
* fix: auto-create state directory before opening SQLite database

NewSQLiteTracker failed with SQLITE_CANTOPEN (unable to open database
file) when the state directory (default ~/.gphoto2proton/state) did not
exist, because the parent directory was never created. Ensure the parent
directory is created with os.MkdirAll before opening the database.

* fix: send Proton-compliant app-version and user-agent headers

The sync command failed on the very first auth request
(400 POST https://mail.proton.me/api/auth/v4/info, Code=2064):
"Application platform and product must be separated by a dash ('-')".

NewUploader set both x-pm-appversion and User-Agent to the bare
"gphoto2proton" string. Proton only accepts:

- x-pm-appversion in the third-party format
  external-drive-<project>@<semver-version> where the project name
  conforms to (-[a-z_]+)+ (digits are rejected), e.g.
  [email protected]
- User-Agent in the <platform>-<product> format, e.g.
  linux-gphoto2proton (platform derived from runtime.GOOS)

AlbumAdapter.doOnce sent the same non-compliant "gphoto2proton/1.0"
user agent to photos-api.proton.me and now reuses protonUserAgent().

Adds unit tests enforcing both header formats.

* fix: use live-verified Proton app-version, send it on photos-api too

Review follow-up: probing the real POST /auth/v4/info endpoint showed
the live server rules differ from the regex published in
rclone/rclone#9189:

- the project name must be a SINGLE section: inner dashes are rejected
  with 2064 "Invalid section name"
  ([email protected] fails live)
- underscores are fine (external-drive-gphoto_proton@... passes)
- digits and a bare semver are accepted live, but we keep the stricter
  published intersection (letters+underscores, explicit -stable
  channel) to be robust against future server-side tightening

protonAppVersion is now [email protected],
verified live: the exact request that failed in the PR description
(400 / Code 2064) now passes.

Also send x-pm-appversion on the hand-rolled photos-api calls in
AlbumAdapter (the header was missing entirely there), correct the
User-Agent comments/tests (the UA format is not actually validated
server-side; the 2064 dash error refers to x-pm-appversion), and add
env-gated live integration tests (auth headers regression + album
create/delete round-trip) that skip without credentials.

Note: full login currently stops at POST /auth/v4 with 422 Code=9001
(CAPTCHA challenge) — Proton anti-abuse risk scoring, unrelated to
these headers; a dummy login gets the expected 2001 instead.

---------

Co-authored-by: mmornati <[email protected]>
mmornati pushed a commit to mmornati/gphoto2proton that referenced this pull request Aug 1, 2026
…r uploads

Live end-to-end testing against Proton Drive (drive-api.proton.me)
surfaced three issues that only appear with a real account:

1. ensureFolder passed targetState=0 to SearchByNameInActiveFolderByID.
   In rclone/go-proton-api, LinkStateDraft=0 and LinkStateActive=1, so
   the lookup never matched the existing gphoto2proton folder and
   CreateNewFolderByID failed with 422 Code=2500 (name exists).
   Pass proton.LinkStateActive explicitly.

2. Failed/interrupted uploads leave draft links/revisions on the
   server. The bridge default ReplaceExistingDraft=false then refuses
   every retry with ErrDraftExists, permanently blocking those files.
   Set ReplaceExistingDraft=true so retries clean up and proceed.

3. POST /drive/blocks rejects every third-party x-pm-appversion except
   rclone's with HTTP 400 Code=2000 ("outdated version of the app").
   Proton keeps a server-side compatibility exception keyed on the
   external-drive-rclone name until the Proton Drive SDK is stable
   (Proton Drive engineer, rclone/rclone#9189). Verified live: the same
   request succeeds with [email protected] and fails
   with [email protected]. Switch the identifier
   and document why, with a note to revert once third-party clients are
   allowlisted.
mmornati added a commit to mmornati/gphoto2proton that referenced this pull request Aug 1, 2026
…ion + draft handling) (#19)

* fix: upgrade Proton Drive libs to rclone forks for crypto-refresh uploads

The 2023-era henrybear327 Proton-API-Bridge/go-proton-api pair does not
implement Proton's crypto-refresh protocol (v6 node keys, v2 SEIPD
blocks, per-block verification). Proton rejects block uploads made with
it on /drive/blocks with HTTP 400 Code=2000 "You are using an outdated
version of the app. Please update to upload this file." Login still
succeeded because auth endpoints accept the old protocol, so the failure
only surfaced during upload.

Switch to the actively maintained rclone forks which implement the
current protocol:

- github.com/rclone/Proton-API-Bridge v1.0.4 (was henrybear327 v1.0.0)
- github.com/rclone/go-proton-api v1.0.3 (was henrybear327 pseudoversion)

Also bump modernc.org/sqlite to v1.55.0 (latest stable).

API compatibility verified: NewProtonDrive, UploadFileByReader,
SearchByNameInActiveFolderByID, CreateNewFolderByID, RootLink and the
common.Config/ReusableCredentialData structs keep identical signatures,
so the only import-site change is the module path. The new manager
targets Proton's recommended drive-api.proton.me endpoint; imported
sessions are domain-independent and keep working with --import-session.

Closes the sync upload failure (400 Code=2000).

* fix: replace stale drafts, search active links, identify as rclone for uploads

Live end-to-end testing against Proton Drive (drive-api.proton.me)
surfaced three issues that only appear with a real account:

1. ensureFolder passed targetState=0 to SearchByNameInActiveFolderByID.
   In rclone/go-proton-api, LinkStateDraft=0 and LinkStateActive=1, so
   the lookup never matched the existing gphoto2proton folder and
   CreateNewFolderByID failed with 422 Code=2500 (name exists).
   Pass proton.LinkStateActive explicitly.

2. Failed/interrupted uploads leave draft links/revisions on the
   server. The bridge default ReplaceExistingDraft=false then refuses
   every retry with ErrDraftExists, permanently blocking those files.
   Set ReplaceExistingDraft=true so retries clean up and proceed.

3. POST /drive/blocks rejects every third-party x-pm-appversion except
   rclone's with HTTP 400 Code=2000 ("outdated version of the app").
   Proton keeps a server-side compatibility exception keyed on the
   external-drive-rclone name until the Proton Drive SDK is stable
   (Proton Drive engineer, rclone/rclone#9189). Verified live: the same
   request succeeds with [email protected] and fails
   with [email protected]. Switch the identifier
   and document why, with a note to revert once third-party clients are
   allowlisted.

---------

Co-authored-by: mmornati <[email protected]>
tom-barone added a commit to tom-barone/proton-drive-photos-export that referenced this pull request Aug 10, 2026
The app announced itself as [email protected], impersonating
the official macOS Drive client. Proton has asked third-party tools to
stop doing this (rclone/rclone#9189): it pollutes their client metrics
and risks sudden breakage if they force-upgrade the impersonated
client.

Proton's sanctioned format is external-drive-<project>@<version>, but
the API rejects unregistered project names ('Invalid section name'), so
use rclone's registered [email protected] string,
which at least identifies the traffic as a third-party client.
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.

2 participants