Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version v1.2.10 does not support MFA #467

Closed
AT181903 opened this issue Oct 21, 2023 · 15 comments
Closed

Version v1.2.10 does not support MFA #467

AT181903 opened this issue Oct 21, 2023 · 15 comments
Labels
Critical The bug is disruptive and requires immediate fix Feature request

Comments

@AT181903
Copy link

AT181903 commented Oct 21, 2023

After installing v1.2.10 when i try to set up the component, it show me "An unexpected error occurred". I tired to reinstall it removing meross_cloud folder from custom_components but nothing happened.
Then I switched back to v1.2.8 and it worked.

Home Assistant 2023.10.3
Supervisor 2023.10.0
Operating System 11.0
Frontend 20231005.0
Hardware environment: Raspberry Pi 4

LOG:

Error Message: "An exception occurred while setting up the meross manager. Setup will be retried..."
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/meross_iot/http_api.py", line 350, in _async_authenticated_post
    error = ErrorCodes(code)
            ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 712, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 1128, in __new__
    raise ve_exc
ValueError: 1033 is not a valid ErrorCodes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/meross_cloud/__init__.py", line 470, in async_setup_entry
    await meross_coordinator.initial_setup()
  File "/config/custom_components/meross_cloud/__init__.py", line 150, in initial_setup
    self._client, http_devices, creds_renewed = await get_or_renew_creds(
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/meross_cloud/__init__.py", line 340, in get_or_renew_creds
    http_client = await MerossHttpClient.async_from_user_password(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/meross_iot/http_api.py", line 117, in async_from_user_password
    creds = await cls.async_login(email=email,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/meross_iot/http_api.py", line 246, in async_login
    response_data = await MerossHttpClient._async_authenticated_post(url=url,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/meross_iot/http_api.py", line 352, in _async_authenticated_post
    raise AuthenticatedPostException(f"Unknown/Unhandled response code received from API. "
meross_iot.model.http.exception.AuthenticatedPostException: Unknown/Unhandled response code received from API. Response was: {'apiStatus': 1033, 'sysStatus': 0, 'info': '', 'timestamp': 1697888019, 'data': {}}
@albertogeniola albertogeniola added the bug Something isn't working label Oct 21, 2023
@albertogeniola
Copy link
Owner

Error 1033 stands for "MFA is required". That means you have enabled multi-factor authentication and that is not yet supported by the current version. You should either downgrade to previous version (which relied on a different API endpoint) or wait for a new release.

@albertogeniola albertogeniola added the Critical The bug is disruptive and requires immediate fix label Oct 21, 2023
@albertogeniola albertogeniola pinned this issue Oct 21, 2023
@AT181903
Copy link
Author

Error 1033 stands for "MFA is required". That means you have enabled multi-factor authentication and that is not yet supported by the current version. You should either downgrade to previous version (which relied on a different API endpoint) or wait for a new release.

Yes, I confirm that I have 2FA enabled on Meross account. Thanks for your reply.

@albertogeniola
Copy link
Owner

Glad you sorted it out :)

@albertogeniola albertogeniola changed the title Version v1.2.10 doesn't work, switching back to 1.2.8 fixed it Version v1.2.10 does not support MFA Jan 27, 2024
@Japtan
Copy link

Japtan commented Feb 5, 2024

Hello. I am very new to Homeassitant as I unboxed my Green box 1 week ago. So sorry if I missed something key...

I installed the version 1.2.12, and I stumbled on this MFA error. So, I downgraded to 1.2.8 and now get "Unable to connect to Meross HTTP api, ex: Failed request to API. Response code: 404". I tried both https://iotx-eu.meross.com/ and https://iot.meross.com. I think the 404 error code is misleading as I received an answer from these adresses with 1.2.12. Would it mean that Meross decomissioned the old API? Should I use another endpoint with 1.2.8? Is 1.2.12 actually supporting 2FA and I am doing something wrong?
Thanks for your help.

@simo1920ca
Copy link

simo1920ca commented Feb 7, 2024

Hello. I am very new to Homeassitant as I unboxed my Green box 1 week ago. So sorry if I missed something key...

I installed the version 1.2.12, and I stumbled on this MFA error. So, I downgraded to 1.2.8 and now get "Unable to connect to Meross HTTP api, ex: Failed request to API. Response code: 404". I tried both https://iotx-eu.meross.com/ and https://iot.meross.com. I think the 404 error code is misleading as I received an answer from these adresses with 1.2.12. Would it mean that Meross decomissioned the old API? Should I use another endpoint with 1.2.8? Is 1.2.12 actually supporting 2FA and I am doing something wrong? Thanks for your help.

I've got the same issue, now i've version 1.2.10 and nothing is working

@AT181903
Copy link
Author

Hi @albertogeniola, does the version 1.2.13 support MFA?

@albertogeniola
Copy link
Owner

Hi @AT181903 , not yet :(

@daviddst
Copy link

Hi,

I don't have MFA setup on my account but I have the same error.

I've tried release 1.2.8 and latest, I couldn't use the service anymore.

Could I do something in order to restore the service ?

Thank you,

@albertogeniola albertogeniola added this to the Version v1.3.1 milestone Apr 25, 2024
@albertogeniola
Copy link
Owner

Hi everybody,

I've just releases version v1.3.1beta1, which implements MFA support. It's still a beta and I need some volunteers to try it and provide feedbacks. Can anyone help?

@albertogeniola albertogeniola added waiting validation Waiting for user's test/validation and removed bug Something isn't working labels Apr 25, 2024
@daviddst
Copy link

Hi everybody,

I've just releases version v1.3.1beta1, which implements MFA support. It's still a beta and I need some volunteers to try it and provide feedbacks. Can anyone help?

With this release, all my devices have been detected and run properly !

I'll come back here if a see any issue.

Great job, thank you very much !!!

@albertogeniola
Copy link
Owner

Great. I've just released a new official stable version, v1.3.1, which includes these changes.
Closing for now:, but feel free to open again if needed.

@albertogeniola albertogeniola removed the waiting validation Waiting for user's test/validation label Apr 28, 2024
@AT181903
Copy link
Author

AT181903 commented Apr 28, 2024

Great. I've just released a new official stable version, v1.3.1, which includes these changes.

Closing for now:, but feel free to open again if needed.

Just updated, but it doesn't work (it tells me "An unexpected error occurred").
In addition, where does it suppose to ask me my 2FA code?

P.S. I can’t reopen the issue since I’m not repo owner, could you do it? Thank you

@albertogeniola
Copy link
Owner

Just updated, but it doesn't work (it tells me "An unexpected error occurred").
In addition, where does it suppose to ask me my 2FA code?

P.S. I can’t reopen the issue since I’m not repo owner, could you do it? Thank you

The 2FA code is shown only if needed/asked by the server backend. In general, when you log in without a 2FA code to an account that requires one, the server returns a specific error code. The component intercepts that error code and shows the 2FA input.

To further investigate, can you post the logs showing up when you try the authentication? It should include a detailed explanation about the error.

@AT181903
Copy link
Author

AT181903 commented Apr 28, 2024

Just updated, but it doesn't work (it tells me "An unexpected error occurred").
In addition, where does it suppose to ask me my 2FA code?

P.S. I can’t reopen the issue since I’m not repo owner, could you do it? Thank you

The 2FA code is shown only if needed/asked by the server backend. In general, when you log in without a 2FA code to an account that requires one, the server returns a specific error code. The component intercepts that error code and shows the 2FA input.

To further investigate, can you post the logs showing up when you try the authentication? It should include a detailed explanation about the error.

This is the error found in homeassistant log file:

Component version: 0.4.7.1
Device info: 
<Unavailable>
Error Message: "An exception occurred while setting up the meross manager. Setup will be retried..."
Traceback (most recent call last):
  File "/config/custom_components/meross_cloud/__init__.py", line 144, in initial_setup
    self._client, http_devices, creds_renewed = await get_or_test_creds(
                                                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/meross_cloud/__init__.py", line 342, in get_or_test_creds
    http_devices = await http_client.async_list_devices()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/meross_iot/http_api.py", line 477, in async_list_devices
    result = await MerossHttpClient._async_authenticated_post(url=url,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/meross_iot/http_api.py", line 375, in _async_authenticated_post
    raise TokenExpiredException("The provided token has expired")
meross_iot.model.http.exception.TokenExpiredException: The provided token has expired

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/meross_cloud/__init__.py", line 421, in async_setup_entry
    await meross_coordinator.initial_setup()
  File "/config/custom_components/meross_cloud/__init__.py", line 150, in initial_setup
    raise ConfigEntryAuthFailed from err
homeassistant.exceptions.ConfigEntryAuthFailed: The provided token has expired
2024-04-28 22:16:15.289 ERROR (MainThread) [custom_components.meross_cloud.config_flow] Unable to connect to Meross HTTP api, ex: Failed request to API. Response code: 404
Traceback (most recent call last):
  File "/config/custom_components/meross_cloud/config_flow.py", line 283, in async_step_configure_manager
    creds = await self._test_authorization(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/meross_cloud/config_flow.py", line 383, in _test_authorization
    client = await MerossHttpClient.async_from_user_password(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/meross_iot/http_api.py", line 119, in async_from_user_password
    creds = await cls.async_login(email=email,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/meross_iot/http_api.py", line 249, in async_login
    response_data = await MerossHttpClient._async_authenticated_post(url=url,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/meross_iot/http_api.py", line 351, in _async_authenticated_post
    raise AuthenticatedPostException("Failed request to API. Response code: %s" % str(response.status))
meross_iot.model.http.exception.AuthenticatedPostException: Failed request to API. Response code: 404
2024-04-28 22:17:05.429 WARNING (MainThread) [custom_components.meross_cloud] Skip MQTT cert validation option set to: False
2024-04-28 22:17:05.660 ERROR (MainThread) [custom_components.meross_cloud] Error occurred.
-------------------------------------

@AT181903
Copy link
Author

I just tried to skip MQTT validation and it seems to work (it asked 2FA code and everything is working)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Critical The bug is disruptive and requires immediate fix Feature request
Projects
None yet
Development

No branches or pull requests

5 participants