madmachinations / home-assistant-alexa-shopping-list

A custom component for Home Assistant which synchronises your Alexa Shopping List
GNU General Public License v3.0
30 stars 3 forks source link

MFA not asked #21

Closed lucasborin closed 1 week ago

lucasborin commented 1 week ago

Hello everyone,

The client does not ask for the MFA. I receive the Amazon´s SMS with the token, but the client does not ask for it, even if I stop/start/restart the server addon.

In the client side:

(venv) ➜  client git:(main) ✗ python3 client.py 172.26.115.87
Alexa Shopping List Sync Client Console.

Attempting to connect to ws://172.26.115.87:4000
Connected successfully

Checking config
Config is invalid, performing setup...

Enter the base url you use to access Amazon (amazon.co.uk): amazon.com.br

Checking authentication
Server is not authenticated with Amazon, beginning login...

Enter your Amazon login details
Email address: lucasborindev@gmail.com
Password:

UNKNOWN ERROR: Already logged in

Enter your Amazon login details
Email address: lucasborindev@gmail.com
Password: 
Server is authenticated

Type 'help' for commands.

> list
ERROR: Not authenticated
>

In the add-on side (server):

connection handler failed
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/websockets/legacy/server.py", line 245, in handler
    await self.ws_handler(self)
  File "/usr/lib/python3.12/site-packages/websockets/legacy/server.py", line 1188, in _ws_handler
    return await cast(
           ^^^^^^^^^^^
  File "/server/server.py", line 258, in _process_command
    results = await _route_command(command, arguments)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/server/server.py", line 226, in _route_command
    return await _cmd_login(arguments)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/server/server.py", line 136, in _cmd_login
    instance.login(args['email'], args['password'])
  File "/server/alexa.py", line 196, in login
    self._handle_login()
  File "/server/alexa.py", line 184, in _handle_login
    self._handle_login_password_page()
  File "/server/alexa.py", line 159, in _handle_login_password_page
    self.driver.find_element(By.NAME, 'rememberMe').click()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 748, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="rememberMe"]"}
  (Session info: chrome=128.0.6613.119); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception

It is a WSL with Debian, HASS Supervised (2024.10.1), with the addon version 2409.259.

Is it related to #11?

lucasborin commented 1 week ago

rememberMe is there:

image

lucasborin commented 1 week ago

Issue resolved. The client (running under WSL) was somehow reusing Windows Edge authentication. After logging out, the client successfully connected.