rclone: Proton Drive: error 422 due to authenticating using an empty access token?

What is the problem you are having with rclone?

Can’t access Proton Drive. I get an HTTP error 422.

What is your rclone version (output from rclone version)

michal@dzieni ~ % rclone version
rclone v1.66.0
- os/version: darwin 14.3.1 (64 bit)
- os/kernel: 23.3.0 (arm64)
- os/type: darwin
- os/arch: arm64 (ARMv8 compatible)
- go/version: go1.22.1
- go/linking: dynamic
- go/tags: none

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

macOS 14.3.1 (23D60), 64-bit

Which cloud storage system are you using? (e.g. Google Drive)

Proton Drive

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

rclone lsd proton:

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

michal@dzieni ~ % rclone lsd proton: -vv           
2024/05/23 17:06:37 DEBUG : rclone: Version "v1.66.0" starting with parameters ["rclone" "lsd" "proton:" "-vv"]
2024/05/23 17:06:37 DEBUG : Creating backend with remote "proton:"
2024/05/23 17:06:37 DEBUG : Using config file from "/Users/michal/.config/rclone/rclone.conf"
2024/05/23 17:06:37 DEBUG : proton drive root link ID '': Has cached credentials
2024/05/23 17:06:37.378288 WARN RESTY 401 GET https://mail.proton.me/api/core/v4/users: Invalid access token (Code=401, Status=401), Attempt 1
2024/05/23 17:06:37.378431 ERROR RESTY 401 GET https://mail.proton.me/api/core/v4/users: Invalid access token (Code=401, Status=401)
2024/05/23 17:06:37.484298 WARN RESTY 422 POST https://mail.proton.me/api/auth/v4/refresh: Invalid refresh token (Code=10013, Status=422), Attempt 1
2024/05/23 17:06:37.484350 ERROR RESTY 422 POST https://mail.proton.me/api/auth/v4/refresh: Invalid refresh token (Code=10013, Status=422)
2024/05/23 17:06:37 DEBUG : Saving config "client_uid" in section "proton" of the config file
2024/05/23 17:06:37 DEBUG : Saving config "client_access_token" in section "proton" of the config file
2024/05/23 17:06:37 DEBUG : Saving config "client_refresh_token" in section "proton" of the config file
2024/05/23 17:06:37 DEBUG : Saving config "client_salted_key_pass" in section "proton" of the config file
2024/05/23 17:06:37 DEBUG : proton drive root link ID '': Cached credential doesn't work, clearing and using the fallback login method
2024/05/23 17:06:37 DEBUG : Saving config "client_uid" in section "proton" of the config file
2024/05/23 17:06:37 DEBUG : Saving config "client_access_token" in section "proton" of the config file
2024/05/23 17:06:37 DEBUG : Saving config "client_refresh_token" in section "proton" of the config file
2024/05/23 17:06:37 DEBUG : Saving config "client_salted_key_pass" in section "proton" of the config file
2024/05/23 17:06:37 DEBUG : proton drive root link ID '': couldn't initialize a new proton drive instance using cached credentials: failed to refresh auth: failed to refresh auth, de-auth: 422 POST https://mail.proton.me/api/auth/v4/refresh: Invalid refresh token (Code=10013, Status=422)
2024/05/23 17:06:37 DEBUG : proton drive root link ID '': Using username and password to log in
2024/05/23 17:06:38.566218 WARN RESTY 422 POST https://mail.proton.me/api/auth/v4: We are detecting potentially abusive traffic coming from your network and have temporarily blocked logins. If you believe this is in error, please contact us here: https://proton.me/support/appeal-abuse (Code=2028, Status=422), Attempt 1
2024/05/23 17:06:38.566270 ERROR RESTY 422 POST https://mail.proton.me/api/auth/v4: We are detecting potentially abusive traffic coming from your network and have temporarily blocked logins. If you believe this is in error, please contact us here: https://proton.me/support/appeal-abuse (Code=2028, Status=422)
2024/05/23 17:06:38 Failed to create file system for "proton:": couldn't initialize a new proton drive instance: 422 POST https://mail.proton.me/api/auth/v4: We are detecting potentially abusive traffic coming from your network and have temporarily blocked logins. If you believe this is in error, please contact us here: https://proton.me/support/appeal-abuse (Code=2028, Status=422)

Thoughts

Here is a config for this remote:

[proton]
type = protondrive
username = SECRET
password = SECRET

I think the problem is following:

  • The app believes that there are cached OAuth credentials (which is not true) and tries to authenticate with empty values.
  • The request gets rejected (401).
  • The app falls back to username & password auth.
  • It doesn’t work though, because the previous attempts lead to marking the traffic as suspicious.

I believe if the app had started immediately with username & password auth, it would be just fine.

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don’t comment if you have no relevant information to add. It’s just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 29
  • Comments: 20 (4 by maintainers)

Most upvoted comments

Feels like Proton might be blocking rclone based on the app version. I’m running daily backups with pure rclone as well as my own implementation done with https://github.com/henrybear327/Proton-API-Bridge, both has been failing for the past 3 days.

If I keep the original app version of macos-drive@1.0.0-alpha.1+rclone I get blocked with We are detecting potentially abusive traffic coming from your network and have temporarily blocked logins. etc

If I remove +rclone in the app version I can immediately login from both rclone and my own implementation.

If I remove +proton in the app version I can immediately login from both rclone and my own implementation.

I think you mean removing +rclone from the app version maybe? This worked for me:

rclone lsd protondrive: --protondrive-app-version "macos-drive@1.0.0-alpha.1"

Thanks for figuring this out!

I have found that this issue a) persists and b) might be much less complicated than it appears.

First of all, having ‘rclone’ in the app-name string does not seem to cause any problems, or at least not anymore: image

Secondly, I have found

client_uid =
client_access_token =
client_refresh_token =
client_salted_key_pass =

in my rclone config after the failed login attempt, which is obviously done by rclone, not Proton.

If there is a connection problem, in my case a simple timeout, the session info is wiped by rclone. I assume this is done to rule out that the problem is with the session, rather than something else. However, this does not work well at all in the case of Proton!

  1. If a user has 2FA enabled, wiping the session info means 2FA is required again, so manual intervention is required at this point.
  2. It seems that logins through a VPN (surprisingly even ProtonVPN) get blocked by Proton Sentinel. I am not sure why exactly, because for example for Android apps or in a browser it works, but with rclone it does not. This means VPN users have to completely disable VPN before being able to login again.

In sum, I think at leat for Proton, rclone should reconsider the session info wipes. It seriously negatively impacts the user experience of anyone using 2FA (which should be anyone 😛) and even more so if you use any VPN.

I’ve contacted Proton using URL received in the error and that’s their response:

Hello,

Thank you for your message.

Please note that this error message shows when we detect suspicious or abusive behavior from a specific network. This is part of our anti-abuse measures meant to protect the service and our users’ accounts from abusers.

If you are using Rclone, please refrain from using it, this should help solve the issue. If you are using a VPN service, we suggest connecting to a different server or disabling the connection temporarily.

Please refer to the following article for a more technical explanation of the issue and for further troubleshooting steps: https://proton.me/support/log-in-temporarily-blocked

Kind regards,

Riley Customer Support Proton Abuse Team

Does that mean that Proton offically bans rclone? 😞

Here is my response, hopefully we can fix it:

Hello,

Do I understand correctly that you officially ban the usage of Proton Drive with rclone? That is really worrying, as that tool fills multiple functionality gaps of cloud services, including yours. Please look at the positive feedback of Proton Drive support in rclone: https://www.reddit.com/r/ProtonDrive/comments/16g53i5/protondrive_with_rclone/.

Is there anything that rclone maintainers can do better to be accepted by your servers? If not, I have to reconsider my subscription.

Kind regards, Michał Dzienisiewicz

I moved to Filen.io and am happy.

@thawthorn Yeah! I thought that’s what I said, sorry if I worded it badly 😛 Glad it worked for you as well

Edit: Ohhhh, now I see what you mean. Updated my original answer, thanks for pointing it out!

I got the same problem at basically the same time. I could imagine that it is Proton blocking rclone. I would be interested to know if anyone has managed to log in with rclone in the last time.

Additionally I am able to log into the Proton webapp and the security log contains a blocked “Sign in attempt” from “macos-drive 1.0.0-alpha.1+rclone”.

@fhoekstra I don’t see why not. Basically all they do is take your .conf exactly as is and backup/restore it.

pre_sync.fish will create a backup of the .conf if there is a session ID found. If this is not the case, it will attempt to restore from an existing backup, given there is one and it contains a session ID.

post_sync.fish is a bit more complex. It creates a hook that will be executed after whatever background process is started before it (using the $last_pid variable that is built into fish).

What is does is creating/refreshing your backup if it reads exit code 0. If it detects a non-zero exit, it will test whether your current .conf still holds a session ID. If this is not the case, it will look for a backup. If there is one and it contains a session ID, it will restore it.

So far, I haven’t experienced any issue while running restic backups and rclone bisyncs with these scripts in place. However, I want to stress that it’s just a quick-n-dirty solution I came up with! I am not working on this project in any official capacity.

I use some fish scripts that backup and restore the config as needed atm:

pre_sync.fish

set curr_id (cat /home/user/.config/rclone/rclone.conf | string match -g -r "client_uid = (.*)")
set old_id (cat /home/user/.config/rclone/rclone.conf.old | string match -g -r "client_uid = (.*)")

if test -z "$curr_id"
    if test -n "$old_id"
        cp /home/user/.config/rclone/rclone.conf.old /home/user/.config/rclone/rclone.conf
    end
else
    cp /home/user/.config/rclone/rclone.conf /home/user/.config/rclone/rclone.conf.old
end

post_sync.fish

# Catch exit status and check whether rclone deleted session info (error case)
function post_sync --on-process-exit $last_pid
    set -g sync_status $argv[3]
    if test $argv[3] -eq 0
        cp /home/user/.config/rclone/rclone.conf /home/user/.config/rclone/rclone.conf.old
    else
        set curr_id (cat /home/user/.config/rclone/rclone.conf | string match -g -r "client_uid = (.*)")
        set old_id (cat /home/user/.config/rclone/rclone.conf.old | string match -g -r "client_uid = (.*)")
        if test -n "$old_id"
            if test -z "$curr_id"
                cp /home/user/.config/rclone/rclone.conf.old /home/user/.config/rclone/rclone.conf
            end
        end
    end
end

Usage:

#!/usr/bin/env fish

source /home/user/scripts/helper/pre_sync.fish

# something using rclone or rclone command with '&' behind it (background process)

source /home/user/scripts/helper/post_sync.fish

# Wait until bg process finished, but check for signals
while ps -p $last_pid > /dev/null
    sleep 4
end

Adjust paths as needed.

Note that this will only work on Linux (or with WSL, Cygwin) and if you have fish shell installed. If you do, you should be able to execute such a script like any other.

I solved the problem by using this: --protondrive-app-version “macos-drive@1.0.0-alpha.1” as suggested.

The second problem now, at least for me, is that i can’t upload files. Rclone says that the proton client is outdated in the logs. Anyone else?