MegaApiClient icon indicating copy to clipboard operation
MegaApiClient copied to clipboard

Error 402 "Payment Required" while login

Open oxmaulmike2581 opened this issue 10 months ago • 6 comments

When I'm trying to log in into my MEGA account using this library, I receieve an error: "Response status code does not indicate success: 402 (Payment Required)." Library version 1.10.4 (initially I used 1.10.3, but upgrading didn't help me). Credentials are valid and I can log in without errors using web browser and MEGA site. This problem started appearing this year (2025). In 2024, with the library version 1.10.3, everything worked fine.

oxmaulmike2581 avatar Feb 04 '25 16:02 oxmaulmike2581

Hello, It seems it's a general issue with Mega. Even the official client displays this error according to https://www.reddit.com/r/MEGA/comments/1hmefp9/unable_to_login_using_megacmd_hangs/

gpailler avatar Feb 07 '25 00:02 gpailler

Any updates on this issue?

Mahdi0024 avatar Feb 25 '25 02:02 Mahdi0024

The LoginAsync and LoginAnonymousAsync methods refuse to return any response, and cause applications to hang, this is happening as early as the 20th of February. I've mailed MEGA asking about more details.

Hello!

I'm a software developer working on an open source project that supports downloading from MEGA (https://github.com/wabbajack-tools/wabbajack/). On the 20th of February we suddenly started getting lots of users that could not download anything from MEGA anymore. When looking into this, I noticed a HTTP 402 code was suddenly returned from the API upon logging in. I also noticed that the problem was resolved as soon as we logged in using an account rather than using an anonymous login to download files.

Were there any API changes recently that may have resulted in this behavior, are anonymous logins no longer allowed to use the API? Would love to hear more details about this, as I cannot find anything about this online. Thanks in advance!

Response from MEGA

Hello trawzified,

Thank you for reaching out.

We have recently added a feature to enhance the security of our platform. This measure requires MEGA client software to solve a complicated mathematical equation during each login attempt. This feature significantly increases the cost for attackers attempting mass-scale unauthorized access to MEGA accounts, protecting you from unauthorised logins by malicious attackers who used to try hundreds of millions of passwords every day.

Outdated official MEGA clients and most third-party tools, including those using the MEGA API, do not currently support solving this mathematical equation and may encounter issues such as the "402 Payment Required" error.

This error does not indicate a problem with your subscription or payment status; instead, it is a response indicating that the login attempt could not fulfil the computational requirement.

To continue using the MEGA API, please log in using an updated MEGA client, such as your web browser in incognito mode.

Once logged in successfully, please use the API again within 24 hours.

Kind regards, MEGA Support

Since this library appears to be deprecated, I think we need to look at other solutions.

tr4wzified avatar Mar 01 '25 18:03 tr4wzified

Thanks for sharing this official explanation from Mega. Have any of you tried this workaround—logging into Mega manually via a web browser before using the API?

gpailler avatar Mar 03 '25 00:03 gpailler

Turns out MEGA implemented some extra security measures, details here: https://github.com/qgustavor/mega/issues/239#issuecomment-2721585713

tr4wzified avatar Mar 18 '25 19:03 tr4wzified

Thanks for sharing this official explanation from Mega. Have any of you tried this workaround—logging into Mega manually via a web browser before using the API?

I can confirm that my users and myself are able to use the library in my application for 24 hours once we log in into the website via browser.

AlexCSDev avatar Apr 05 '25 11:04 AlexCSDev

Hey guys, I opened a PR that should fix this issue: https://github.com/gpailler/MegaApiClient/pull/249

tr4wzified avatar Jul 10 '25 21:07 tr4wzified

Thanks @tr4wzified for this PR! I just merged the changes and a version is available on MyGet 1.10.5-ci0003

Could you test this version and if everything is working properly, I will prepare an official release for NuGet

gpailler avatar Aug 14 '25 07:08 gpailler

Took a while to get to testing this, but I found some time.

For me it hangs on MegaApiClient.Login(). LoginAnonymous() works fine and lets me download files.

AlexCSDev avatar Aug 23 '25 13:08 AlexCSDev

@tr4wzified Did you have a chance to test this MyGet package?

gpailler avatar Aug 27 '25 03:08 gpailler

@tr4wzified Did you have a chance to test this MyGet package?

I understand you're looking for confirmation from @tr4wzified, but I went ahead and tested version 1.10.5-ci0003 from MyGet in our application (a small tool for virtual pinball users to download content from MEGA). Both MEGAClient.LoginAnonymous() and MEGAClient.Login with credentials are working flawlessly on my end. While I haven’t rolled it out in our main setup yet, initial testing shows it works exactly as needed, so I’m optimistic this will solve the issue.

MikedaSpike avatar Sep 09 '25 13:09 MikedaSpike

Thanks for your confirmation @MikedaSpike . I will deploy to Nuget then 🚀

gpailler avatar Sep 10 '25 01:09 gpailler

https://www.nuget.org/packages/MegaApiClient/1.10.5 is published on Nuget. Thanks !

gpailler avatar Sep 10 '25 01:09 gpailler