protondrive: name the remote in the CAPTCHA error and offer browser sign-in in config

A CAPTCHA on password sign-in told the user to reconnect a remote
literally called "remote:". The error from NewFs now names the remote
and is fatal, and rclone config goes back to the choice of sign-in
method with a hint to use the web browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas WintherandClaude Opus 5.5 committed 2026-11-11 17:58:35 +01:00
1 parent c00162ed20
commit 6e2410de69
4 files changed
+19 -3

No files matched your search

+7 -1
View File
@@ -530,8 +530,11 @@ func connect(ctx context.Context, name string, s *session, opt *Options) (*clien
}
fs.Debugf(nil, "protondrive: signing in with username and password")
if err := passwordSignIn(ctx, s, opt, ""); err != nil {
if errors.Is(err, errNeedTwoFA) {
switch {
case errors.Is(err, errNeedTwoFA):
return nil, fmt.Errorf("the account needs a two-factor authentication code: set otp_secret_key or %s", reconnect)
case errors.Is(err, errCaptcha):
return nil, fserrors.FatalError(fmt.Errorf("%w: %s and choose browser sign-in", err, reconnect))
}
return nil, err
}
@@ -621,6 +624,9 @@ password set above.`)
if errors.Is(err, errNeedTwoFA) {
return fs.ConfigInput("password_2fa", "config_2fa", "Two-factor authentication code")
}
if errors.Is(err, errCaptcha) {
return fs.ConfigError("method", "Proton asks for a CAPTCHA, which password sign-in can't solve: sign in with a web browser instead.")
}
if err != nil {
return nil, err
}
@@ -339,6 +339,17 @@ func TestConfigPassword(t *testing.T) {
requireSession(t, srv, m, u)
assert.Empty(t, m["2fa"], "the 2FA code is not saved")
})
t.Run("captcha", func(t *testing.T) {
u := srv.AddUser("usercaptcha", "pass")
srv.RequireCaptcha(u)
m := configmap.Simple{"endpoint": srv.URL(), "username": "usercaptcha", "password": obscure.MustObscure("pass")}
out, err := configure(context.Background(), "test", m, fs.ConfigIn{State: "password"}, signInOptions{})
require.NoError(t, err)
require.NotNil(t, out)
assert.Contains(t, out.Error, "web browser")
assert.Equal(t, "method", out.State, "goes back to the choice of sign-in")
assert.Empty(t, m["client_uid"])
})
t.Run("no password", func(t *testing.T) {
m := configmap.Simple{"endpoint": srv.URL()}
out, err := configure(context.Background(), "test", m, fs.ConfigIn{State: "password"}, signInOptions{})
+1 -1
View File
@@ -34,7 +34,7 @@ var errNotSignedIn = errors.New(`not signed in: run "rclone config reconnect rem
// errCaptcha is returned by password sign-in when Proton asks for human
// verification, which only its sign-in page can do.
var errCaptcha = errors.New(`password sign-in needs a CAPTCHA solved: run "rclone config reconnect remote:" and choose browser sign-in`)
var errCaptcha = errors.New("password sign-in needs a CAPTCHA solved")
const (
// srpBitLength is the bit length of Proton's SRP modulus.
@@ -447,7 +447,6 @@ func TestLoginSRPCaptcha(t *testing.T) {
s, store := newLoginSession(srv)
err := s.loginSRP(context.Background(), "user", "pass", "", noTwoFA)
require.ErrorIs(t, err, errCaptcha)
assert.Contains(t, err.Error(), "rclone config reconnect")
assert.Equal(t, credentials{}, store.Load())
}