Problem to login with mega

What is the problem you are having with rclone?

When I try to connect with mega, I get the following error:

Failed to create file system for "mega2:/:" couldn't login: illegal base64 data at input byte 22

What is your rclone version (output from rclone version)

`rclone version
 rclone v1.49.5
 - os/arch: linux/amd64
 - go version: go1.12.10`

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

Linux Debian 10 64 bits

Which cloud storage system are you using? (eg Google Drive)

Mega

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone ls mega2:/

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

rclone ls mega2:/ -vv
2019/10/12 16:05:29 DEBUG : rclone: Version "v1.49.5" starting with parameters ["rclone" "ls" "mega2:/" "-vv"]
2019/10/12 16:05:29 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2019/10/12 16:05:30 Failed to create file system for "mega2:/": couldn't login: illegal base64 data at input byte 22

The username is the email that has a period between the names: pledin.jds@gmail.com

Thank you

Hmm, I think we've seen this problem before.

Did it ever work?

Does it work if you leave it a bit and try again?

Can you try with the latest beta?

I have another mega account and it works perfectly.

However with this username does not work, I do not know if it can be by the point that has the name.

to my (newbie compared to NCW) understanding the error might indicate some sort of invalid or unexpected character in what it tries to log in with.

Could you perhaps post the relevant section from your rclone.conf file?
of course, obscure any passwords and such, but try to keep them in exactly the same format as much as you can.
rather than just removing them, replace some random characters with another equivalent ones so we can get a sense of if the syntax is wrong somehow - without you compromising the secure info.

Did you create this remote in a different way than you did the working one? Did you at some point copypaste any info into the config directly rather than using the rclone config tool?

It's not impossible, but it's not the first thing I would suspect because a . in an email is perfectly valid and it would have been a grave oversight if the mega API rejected it based on that... and presumably the coders weren't complete amateurs.

I tried making an accout with a . in the user part of the email like yours, but it worked fine...

Can you post the result of this please? Then I can work out which bit of the base64 data it is moaning about

rclone lsf mega2: -vv --dump bodies

If you don't want to post publically then email it to nick@craig-wood.com with a link to the forum post in the email.

The mega2 service was created with the rclone config statement, exactly the same as the one that works.

cat .config/rclone/rclone.conf 
[mega1]
type = mega
user = xxxxxxxxxx@gmail.com
pass = PKLCpzvNuvGelXALgK_1d4mazQwbxJOkbIlDXAo

[mega2]
type = mega
user = xxxxxx.xx@gmail.com
pass = BNO6HeDM7OaCDRZ4eu889WmK9vPFDKzvaOHmgls

Don't see anything wrong here.
I don't really have much else to add to this problem then. Best follow NCW's sintructions and see if those logs reveal anything.

@josedom Thanks for the log file.

I've identified what is happening I think... The upstream library needed to be a bit more permissive when decoding base64 characters.

So can you try this?

https://beta.rclone.org/branch/v1.49.5-213-g48fa6f57-fix-mega-base64-beta/ (uploaded in 15-30 mins)

Hello, I have tried the version that you have indicated to me, and now this error comes out:

> Failed to create file system for "mega2:/": couldn't login: Block decryption failed

I send the dump information to your email

Thank you

Same issue here.
Use rClone as a plugin to unRAID.
Other services work.
Not mega.

Hello, I was wondering if anyone had found a solution to this issue, as it is identical to the one that I find myself having. I am on Linux Mint 18.3, rclone version 1.50.2, go version 1.13.4

Here is my command: rclone ls mega:Books
and my output: 2020/01/09 12:56:28 Failed to create file system for "mega:Books": couldn't login: illegal base64 data at input byte 22

I made a reddit post about it as well https://www.reddit.com/r/rclone/comments/elvowf/help_getting_error_when_trying_to_ls_my_remote/

Can you try the latest beta - that has a slightly new version of the mega library. I don't know whether it will work or not though.

I tried it and had no luck, though it is a different error now

Command: ~ $ rclone --version

Output:
rclone v1.50.2-123-gae340cf7-beta
- os/arch: linux/amd64
- go version: go1.13.5

Command: ~$ rclone ls mega:Books
Output: 2020/01/09 16:46:38 Failed to create file system for "mega:Books": couldn't login: Block decryption failed

Can you do rclone ls mega:Books -vv --dump bodies --log-file mega.log and email me nick@craig-wood.com the log with a link to this issue?

I see if I can find time to analyse the problem.

Thanks

I have this problem with my mega.nz account:

2020/01/11 11:12:32 Failed to create file system for "mega:": couldn't login: Block decryption failed

Looks like the problem is here (from --dump bodies ):

  	{
  		"h": "R5wQ2AIC",
  		"p": "osRGhDhB",
  		"u": "***********",
  		"t": 1,
  		"a": "UkRUlxZ3Znt97YOZy4dsc9P5GYuBj5sepsWaqOnwpaI",
  		"k": "R5wQ2AIC:bRoP1Nb_4Sbazz5jxsbvig/osRGhDhB:cANaNJ0G8_qu42WkuMUfbw",
  		"ts": 1518341297
  	}

k value is:
R5wQ2AIC:bRoP1Nb_4Sbazz5jxsbvig/osRGhDhB:cANaNJ0G8_qu42WkuMUfbw
but in mega.go there is:

args := strings.Split(itm.Key, ":")

We get "bRoP1Nb_4Sbazz5jxsbvig/osRGhDhB" instead of "bRoP1Nb_4Sbazz5jxsbvig" here and blockDecrypt fails.

Looks like adding one more split solves the issue:

  args := strings.Split(strings.Split(itm.Key, "/")[0], ":")

That is great investigation - thanks @Ajaja

I checked with the mega sdk which I think does a similar thing (It is in rather cryptic C++)

I don't really understand what the parameter after the / is for so I've ignored it.

I made an attempt to fix this here

https://beta.rclone.org/branch/v1.50.2-124-gaefe18fc-fix-mega-decode-beta/ (uploaded in 15-30 mins)

I patched the vendor directory in rclone so if it tests out OK then I'l push it up into the go-mega repo and pull it back into rclone.

@zbrasseaux can you try that too?

It worked! Thank you guys! Great job, and great work!

I've tested rclone-v1.50.2-124-gaefe18fc-fix-mega-decode-beta-windows-amd64 with my MEGA account, it works too, thanks!

Thanks for testing :slight_smile: And thanks for @Ajaja for the analysis - that was super helpful.

I've merged this to master now which means it will be in the latest beta in 15-30 mins and released in v1.51

This is the beta it will be in, this one or any subsequent!

https://beta.rclone.org/v1.50.2-125-g92662bac-beta/ (uploaded in 15-30 mins)