Skip to content

[feature request] add support for 2FA in mailru backend #3637

Open

Description

@ivandeex

Mailru backend fails to authorize if two-factor authentication is enabled on user account.
Also, if you try to use passwords that mail.ru generate specially for authorizing apps - you will get the following error:
Failed to create file system for "XXX:": Failed to authorize: oauth2: server response missing access_token
Checked on Windows with Rclone version 1.49.5.

Originally posted by @Heniker in #591 (comment)

Activity

  1. Heniker commented on Oct 18, 2019

    @Heniker

    I am not sure if that is what you're looking for, tho I think this are the links for authorizing apps on mail.ru:
    https://api.mail.ru/docs/guides/social-apps/
    https://api.mail.ru/apps/my/add

    By the password for apps I actually meant this pass, that appears after you connect your 2FA app to mail.ru:

    It appears to be randomly generated 16 digit pass,

    btw, thank you for your great work on integrating mail.ru in Rclone.

  2. ivandeex commented on Oct 18, 2019

    @ivandeex
    MemberAuthor

    Does the app password work with rclone if 2FA is disabled?

  3. Heniker commented on Oct 19, 2019

    @Heniker

    You can't generate new app-passwords or access old once you disable 2FA. I guess they just get deleted and can no longer be used.

  4. ivandeex commented on Oct 22, 2019

    @ivandeex
    MemberAuthor

    I tried to create a test "social" app using your links (http://my.mail.ru/apps/766346) and perform app authorization. Their authorization method requires a browser-based application that is able to capture page loads in subframe. The first redirect during authorization goes to url under mailru refusing to redirect to rclone's localhost url for rclone to capture authorization code. Looks like their "social" app type is not intended for computer based applications, so the problem is not about 2FA (SMS backed user login) alone. This needs further investigation.

  5. ivandeex commented on Oct 25, 2019

    @ivandeex
    MemberAuthor

    Let's summarize current findings on 2FA and 3rd party apps support in mailru. This can be later added in the backend docs.

    A single account is used for the webmail and storage (aka "cloud") services. Only e-mail accounts belonging to Mailru company domains (@mail.ru, @list.ru, @bk.ru, etc) are fully supported. Their online help states that one can use an external (@yandex.ru etc) email but needs to register it with the Mailru mail in advance. In practice this is not generally recommended as it may involve additional OAUTH redirects, not yet tested in rclone. Account registration process is described in the online help (https://help.mail.ru/engmail-help/registration/signup).

    Mailru supports 2FA for user accounts. It can be enabled/disabled on the account security settings screen (https://e.mail.ru/settings/security) which is shared between webmail and "cloud", ie. 2FA is enabled or disabled for both simultaneously.
    mailru-enable-2fa

    Entering your cell number and confirming one-time SMS code activates 2FA on your account for webmail and disk together, and additionally enables another 2FA configuration screen (https://e.mail.ru/settings/2-step-auth) which allows to:

    • configure 3rd party OTP application with reserved OTP codes (unrelated to rclone or mail, just codes)
    • configure 3rd party mail application with an "app code" (see below)
      mailru-3rd-party-app
      mailru-3rd-party-pass
      The code is bound to active 2FA and intended for consumption only by mobile mail applications like TheBat or alike to obtain a token, but cannot be used in "cloud" clients like rclone.

    Enabling 2FA modifies the OAuth handshake performed by Mailru auth servers introducing a 2nd stage, which is currently not supported by rclone. This is unrelated to the "mail app code" depicted above and can be supported in future but needs modifications on rclone side. This ticket will stay open to track the progress, any help is appreciated. A future support for 2FA in rclone will involve some kind of gui/console interface for user to enter SMS codes on a hourly basis (which essentially deteriorates batch modes of operation, btw). Currently it is recommended to disable 2FA on Mailru accounts intended for rclone until it gets eventually implemented.
    mailru-disable-2fa

    Additionally, the mailru developer portal (https://api.mail.ru/docs/guides/social-apps) mentions so-called "social apps" which can be registered (https://api.mail.ru/apps/my/add) by an end user after signing the Mailru developer agreement. The "social apps" are explicitly described in Mailru documentation as javascript-based web applications running in a frame inside Mailru social site "MoiMeer". An experiment has shown that Mailru performs OAUTH token handshake for such apps in a non-standard manner ignoring external URL but redirecting the code-bearing reply to a Mailru subdomain, which should probably be intercepted by javascript from a frame. Adapting a CLI application like rclone to such a pipeline would require invoking the web browser gui with html/js/frame hacks on every token refresh. As this doesn't provide any visible advantage I doubt rclone needs to go for such hacks.

    For the sake of completeness one should mention the proprietary Disk-O: client which supports both user/password and some undocumented authorization methods.

  6. added this to the Known Problem milestone on Oct 25, 2019
  7. self-assigned this
    on May 18, 2020
  8. sbvitok commented on May 21, 2020

    @sbvitok

    [mailru]
    type = webdav
    url = https://webdav.cloud.mail.ru
    vendor = other
    user = ***@mail.ru
    pass = from 3rd party mail application

    Works for me.

  9. modified the milestones: Known Problem, Soon on Nov 5, 2020
  10. modified the milestones: Soon, v1.57 on Apr 4, 2021
  11. modified the milestones: v1.57, Soon on Apr 5, 2021
  12. QuAzI commented on Aug 29, 2021

    @QuAzI

    type = webdav

    Doesn't work with rclone and TotalCommander webdav plugin

    2021/08/29 11:55:02 ERROR : : error listing: couldn't list files: Unavailable: 403 Forbidden
    2021/08/29 11:55:02 Failed to lsd with 2 errors: last error was: couldn't list files: Unavailable: 403 Forbidden
    

    Any other workarounds?

    upd: only works if you have paid account

  13. rocwhite168 commented on Jun 15, 2022

    @rocwhite168

    upd: only works if you have paid account

    It works for me without paid account. I initially got the same "403 Forbidden" error, but after I accessed the mail.ru Cloud on browser (and accepted User Agreement, etc.), it works now through Rclone.

  14. Shkarlatov commented on Jun 29, 2022

    @Shkarlatov

    [mailru]
    type = webdav
    url = https://webdav.cloud.mail.ru
    vendor = other
    user = ***@mail.ru
    pass = from 3rd party mail application

    After append this lines in config, i run rclone config and change pass, because not encrypted password is not accepted.
    You can also check with standard windows tools

    net use O: https://webdav.cloud.mail.ru/ <application password> /user:*******@mail.ru /persistent:no
    

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions