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

Unable to login to amazon.it/amazon.es with 2FA enabled #353

Closed
alandtse opened this issue Sep 8, 2019 · 5 comments · Fixed by #371
Closed

Unable to login to amazon.it/amazon.es with 2FA enabled #353

alandtse opened this issue Sep 8, 2019 · 5 comments · Fixed by #371

Comments

@alandtse
Copy link
Owner

alandtse commented Sep 8, 2019

Describe the bug
Unable to login to amazon.it. The configurator loops at the begin stage.

This appears to only happen for the amazon.it domain.

To Reproduce
Steps to reproduce the behavior:

  1. Set domain to amazon.it
  2. Try to log in using configurator
  3. Configurator loops

Expected behavior
A clear and concise description of what you expected to happen.
Able to log in.

Screenshots
This is the debug page.
image

System details

  • Home-assistant (version): 0.98.5
  • Hassio (Yes/No): (Please note you may have to restart hassio 2-3 times to load the latest version of alexapy after an update. This looks like a HA bug).
  • alexa_media (version from const.py or HA startup): 2.1.2
  • alexapy (version from pip show alexapy or HA startup): 1.1.2

Logs

2019-09-08 22:31:03 DEBUG (MainThread) [alexapy.alexalogin] Processing https://www.amazon.it/ap/signin
2019-09-08 22:31:03 DEBUG (MainThread) [alexapy.alexalogin] Links: {}
2019-09-08 22:31:03 DEBUG (MainThread) [alexapy.alexalogin] Error page detected:
2019-09-08 22:31:03 DEBUG (MainThread) [alexapy.alexalogin] Found post url to get; forcing get to https://www.amazon.it/ap/signin/258-9650445-6341918?ie=UTF8&showRememberMe=true&showRmrMe=1&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&pageId=amzn_dp_project_dee_it&openid.return_to=https%3A%2F%2Falexa.amazon.it%2F&prevRID=RE5Z1SS4JZW7WR3JJA6Z&openid.assoc_handle=amzn_dp_project_dee_it&openid.mode=checkid_setup&prepopulatedLoginId=&failedSignInCount=0&showPasswordChecked=false&rememberMe=true&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&email=alandtse%40gmail.com&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&ubid=260-9272972-XXXXXX/YYY-9650445-6341918?ie=UTF8&email=email%40email.com

Additional context
The root cause is the fact something is causing Amazon to invalidate the cookies in the login process. This does not appear to happen with 2FA disabled. Other domains do not have any issues.

Original reports on 2.1.0:

https://community.home-assistant.io/t/echo-devices-alexa-as-media-player-testers-needed/58639/3123

https://community.home-assistant.io/t/echo-devices-alexa-as-media-player-testers-needed/58639/3141


Ok playing around more with this, it feels like only alexa.it has this problem and only if you have 2FA enabled. I have a new build I'll push that resolves the specific error but not the inability to use 2FA for amazon.it.

Workaround when I do the new release will be to disable 2FA to get the cookie and then reenable.

Originally posted by @alandtse in #344 (comment)

@pippocla
Copy link

pippocla commented Sep 9, 2019

Hi Alandtse,
I update alexapy to 1.1.2 and also the custom component to 2.1.2.
The 2FA is disabled, but I still have the same error.
This is from log HA:

2019-09-09 20:15:01 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.1361617296] get
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1260, in _execute_service
await handler.func(service_call)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/configurator/init.py", line 235, in async_handle_service_call
await self.hass.async_add_job(callback, call.data.get(ATTR_FIELDS, {}))
File "/home/homeassistant/.homeassistant/custom_components/alexa_media/init.py", line 165, in configuration_callback
login, callback_data)
File "/home/homeassistant/.homeassistant/custom_components/alexa_media/init.py", line 155, in setup_platform_callback
await login.login(data=callback_data)
File "/home/homeassistant/.homeassistant/alexapy/alexalogin.py", line 306, in login
headers=self._headers)
File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/client.py", line 466, in _request
ssl=ssl, proxy_headers=proxy_headers, traces=traces)
File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 286, in init
self.update_host(url)
File "/srv/homeassistant/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 340, in update_host
raise InvalidURL(url)
aiohttp.client_exceptions.InvalidURL: get

@alandtse
Copy link
Owner Author

alandtse commented Sep 9, 2019

Can you please enable debug logging on alexapy? Check the wiki for instructions.

@frontegi
Copy link

I had the same issue, I had to disable 2FA to make it work again.

@alandtse alandtse changed the title Unable to login to amazon.it with 2FA enabled Unable to login to amazon.it/amazon.es with 2FA enabled Sep 15, 2019
@alandtse
Copy link
Owner Author

I think I've tracked it down as it looks like aiohttp isn't handling expired cookies properly which gets exposed with the 2FA path. Need to think of a clean workaround. Totally possible it's a configuration error on my end but I'll see if the aiohttp can reproduce the issue.

@alandtse
Copy link
Owner Author

Ended up replacing the cookiejar and submitting a patch request back to aiohttp. Until merged, the PR on gitlab should solve this. I'll stage it for the next release but anyone who is adventurous can manually replace the files.

This was referenced Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants