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

aiohttp.client_exceptions.InvalidUrlClientError: /errors/validateCaptcha - solved by alexapy v1.28.2 but needs manual manifest.json edit #2418

Closed
starkillerOG opened this issue Aug 7, 2024 · 174 comments

Comments

@starkillerOG
Copy link

starkillerOG commented Aug 7, 2024

IMPORTANT: Please search the issues, including closed issues, and the FAQ before opening a new issue. The template is mandatory; failure to use it will result in issue closure.

Describe the bug

When updating to HA 2024.8.0 the alexa_media_player integration unfortunately broke for me.
Was working fine on HA 2024.7.x.
I think this has to do with a version bump of aiohttp.

Following error in the logs:
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 687, in login
    post_resp = await self._session.post(

aiohttp.client_exceptions.InvalidUrlClientError: /errors/validateCaptcha

seems to me like the InvalidUrlClientError needs to be catched and a re-auth flow needs to be initialized.

To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

Initialize a re-auth flow if needed.

Screenshots

System details

  • Home-assistant (version): HA 2024.8.0
  • alexa_media (version from const.py or HA startup): v4.12.5
  • alexapy (version from pip show alexapy or HA startup):
  • Amazon 2FA is enabled (y/n). <!---We will not debug login issues if unanswered--->:
    YES 2FA enabled
    Logs
    Please provide logs.
Logger: homeassistant.config_entries
Source: config_entries.py:604
First occurred: 10:16:34 PM (1 occurrences)
Last logged: 10:16:34 PM
Error setting up entry Amazon Alexa for alexa_media

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/__init__.py", line 359, in async_setup_entry
    await login.login(cookies=await login.load_cookie())
  File "/usr/local/lib/python3.12/site-packages/alexapy/helpers.py", line 137, in wrapper
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py", line 687, in login
    post_resp = await self._session.post(
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 576, in _request
    raise err_exc_cls(url)
aiohttp.client_exceptions.InvalidUrlClientError: /errors/validateCaptcha

Additional context

@UlrichThiess
Copy link

Even if you uninstall the Integration you can't install it.

@Scope666
Copy link

Scope666 commented Aug 7, 2024

Same problem here... I tried uninstalling and reinstalling, and I got this:

2024-08-07 16:43:45.751 WARNING (MainThread) [alexapy.helpers] alexaapi.get_guard_details((<alexapy.alexalogin.AlexaLogin object at 0x149ed2ddea20>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Unauthorized',)
2024-08-07 16:43:45.751 WARNING (MainThread) [alexapy.helpers] alexaapi.get_network_details((<alexapy.alexalogin.AlexaLogin object at 0x149ed2ddea20>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Unauthorized',)
2024-08-07 16:43:45.754 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/alexa_media/__init__.py", line 251, in relogin
    if await test_login_status(hass, config_entry, login_obj):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/__init__.py", line 1421, in test_login_status
    ] = await hass.config_entries.flow.async_init(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1293, in async_init
    flow, result = await self._async_init(flow_id, handler, context, data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1323, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 516, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/config_flow.py", line 578, in async_step_reauth
    reauth_schema = self._update_schema_defaults()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/config_flow.py", line 813, in _update_schema_defaults
    CONF_HASS_URL, default=self.config.get(CONF_HASS_URL, hass_url)
                                                          ^^^^^^^^
NameError: name 'hass_url' is not defined
2024-08-07 16:43:45.755 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/alexa_media/__init__.py", line 251, in relogin
    if await test_login_status(hass, config_entry, login_obj):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/__init__.py", line 1421, in test_login_status
    ] = await hass.config_entries.flow.async_init(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1293, in async_init
    flow, result = await self._async_init(flow_id, handler, context, data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1323, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 516, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/config_flow.py", line 578, in async_step_reauth
    reauth_schema = self._update_schema_defaults()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/config_flow.py", line 813, in _update_schema_defaults
    CONF_HASS_URL, default=self.config.get(CONF_HASS_URL, hass_url)
                                                          ^^^^^^^^
NameError: name 'hass_url' is not defined
2024-08-07 16:43:45.757 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/alexa_media/__init__.py", line 251, in relogin
    if await test_login_status(hass, config_entry, login_obj):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/__init__.py", line 1421, in test_login_status
    ] = await hass.config_entries.flow.async_init(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1293, in async_init
    flow, result = await self._async_init(flow_id, handler, context, data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1323, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 516, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/config_flow.py", line 578, in async_step_reauth
    reauth_schema = self._update_schema_defaults()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/config_flow.py", line 813, in _update_schema_defaults
    CONF_HASS_URL, default=self.config.get(CONF_HASS_URL, hass_url)
                                                          ^^^^^^^^
NameError: name 'hass_url' is not defined
2024-08-07 16:43:45.758 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/config/custom_components/alexa_media/__init__.py", line 251, in relogin
    if await test_login_status(hass, config_entry, login_obj):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/__init__.py", line 1421, in test_login_status
    ] = await hass.config_entries.flow.async_init(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1293, in async_init
    flow, result = await self._async_init(flow_id, handler, context, data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1323, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 516, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/config_flow.py", line 578, in async_step_reauth
    reauth_schema = self._update_schema_defaults()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/alexa_media/config_flow.py", line 813, in _update_schema_defaults
    CONF_HASS_URL, default=self.config.get(CONF_HASS_URL, hass_url)
                                                          ^^^^^^^^
NameError: name 'hass_url' is not defined
2024-08-07 16:43:45.846 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 0.3s (aiohttp.client_exceptions.ClientConnectionError: Connector is closed.)
2024-08-07 16:43:45.927 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 0.2s (aiohttp.client_exceptions.ClientConnectionError: Connector is closed.)
2024-08-07 16:43:45.934 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 0.6s (aiohttp.client_exceptions.ClientConnectionError: Connector is closed.)
2024-08-07 16:43:46.153 WARNING (MainThread) [alexapy.helpers] alexaapi.get_authentication((<alexapy.alexalogin.AlexaLogin object at 0x149ed2ddea20>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Login error detected; not contacting API',)
2024-08-07 16:43:46.178 WARNING (MainThread) [alexapy.helpers] alexaapi.get_devices((<alexapy.alexalogin.AlexaLogin object at 0x149ed2ddea20>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Login error detected; not contacting API',)
2024-08-07 16:43:46.262 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 0.2s (aiohttp.client_exceptions.ClientConnectionError: Connector is closed.)
2024-08-07 16:43:46.268 INFO (MainThread) [alexapy.alexaapi] Backing off _static_request(...) for 1.0s (aiohttp.client_exceptions.ClientConnectionError: Connector is closed.)
2024-08-07 16:43:46.482 WARNING (MainThread) [alexapy.helpers] alexaapi.get_device_preferences((<alexapy.alexalogin.AlexaLogin object at 0x149ed2ddea20>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Login error detected; not contacting API',)
2024-08-07 16:43:46.531 WARNING (MainThread) [alexapy.helpers] alexaapi.get_dnd_state((<alexapy.alexalogin.AlexaLogin object at 0x149ed2ddea20>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Login error detected; not contacting API',)
2024-08-07 16:43:46.546 INFO (MainThread) [homeassistant.components.automation.kitchen_hats_auto_on] Kitchen Hats Auto ON: Running automation actions
2024-08-07 16:43:46.546 INFO (MainThread) [homeassistant.components.automation.kitchen_hats_auto_on] Kitchen Hats Auto ON: Executing step call service
2024-08-07 16:43:47.227 WARNING (MainThread) [alexapy.helpers] alexaapi.get_bluetooth((<alexapy.alexalogin.AlexaLogin object at 0x149ed2ddea20>,), {}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments:
('Login error detected; not contacting API',)

@stephenmhall
Copy link

this isnt to do with the fact the Alexa web page we used to be able to access has gone and it points you to an app install? I have been unable to use the integration for a few updates now.

@stephenmhall
Copy link

and, if you click "install the app" it loads up an Amazon app store which tells you it is no longer supported on Windows 11 and all the apps will no longer be supported, and you dont seem to be able to install anything from it. Sorry if tis isn't relevant.

@Scialla
Copy link

Scialla commented Aug 7, 2024

same problem here, tried 2 time to remove and reinstall integration but can't install it

@Jeepmb
Copy link

Jeepmb commented Aug 7, 2024

Same issue here on upgrade to 2024.8

@expozeur
Copy link

expozeur commented Aug 7, 2024

Same issue.

@Scope666
Copy link

Scope666 commented Aug 7, 2024

Downgraded back to 2024.7.4 and it's working again, so something definitely broke this in 2024.8

@MidnightLink
Copy link

MidnightLink commented Aug 7, 2024

For anyone having this same issue, you can rollback your HA version by using Advanced SSH Terminal and inputting

ha core update --version=2024.7.4

Error log on 2024.8.1:

Logger: alexapy.helpers Source: custom_components/alexa_media/__init__.py:359 integration: Alexa Media Player ([documentation](https://github.com/alandtse/alexa_media_player/wiki), [issues](https://github.com/alandtse/alexa_media_player/issues)) First occurred: 5:30:17 PM (1 occurrences) Last logged: 5:30:17 PM alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7f67c5c18170>,), {'cookies': {}}): An error occurred accessing AlexaAPI: An exception of type InvalidUrlClientError occurred. Arguments: (URL('/errors/validateCaptcha'),)

@L81ker
Copy link

L81ker commented Aug 7, 2024

I have the same. I set debug on. Was working fine prior to 2024.8.

Note that I have cleaned my PIA data from this debug log, username is replaced with <<>>
Alexa-Amazon-debug-log-redacted.txt

@mazdarx2001
Copy link

For anyone having this same issue, you can rollback your HA version by using Advanced SSH Terminal and inputting

ha core update --version=2024.7.4

Thanks for this. I rolled mine back and can confirm its now working! Definitely keeping this version until I see a fix.

@BobMac57
Copy link

BobMac57 commented Aug 7, 2024

For anyone having this same issue, you can rollback your HA version by using Advanced SSH Terminal and inputting
ha core update --version=2024.7.4

Thanks for this. I rolled mine back and can confirm its now working! Definitely keeping this version until I see a fix.

Same here...

@ob1w4nken0b1
Copy link

same here, unfortunately

@guitosi
Copy link

guitosi commented Aug 7, 2024

same here, 2024.08.0

@jbrown9100
Copy link

Downgraded back to 2024.7.4 and it's working again, so something definitely broke this in 2024.8

It seems to me, that it may have to do with the unification of Services into Actions that something broke. 2024.7.4 put Services back.

@guitosi
Copy link

guitosi commented Aug 7, 2024

Downgraded back to 2024.7.4 and it's working again, so something definitely broke this in 2024.8

It seems to me, that it may have to do with the unification of Services into Actions that something broke. 2024.7.4 put Services back.

Thanks man, I downgraded and it worked again as you mentioned

@bdraco

This comment was marked as outdated.

@bdraco
Copy link

bdraco commented Aug 7, 2024

https://github.com/aio-libs/aiohttp/pull/8158/files#diff-f334e752b4894ef951105572ab8b195aeb8db90eb6e48b1dfbd9a01da4c854f5R530

It looks like this PR added the exception where its raising but the comment in that PR implies it would fail anyways later

@IainPHay
Copy link

IainPHay commented Aug 7, 2024

Downgraded back to 2024.7.4 and it's working again, so something definitely broke this in 2024.8

It seems to me, that it may have to do with the unification of Services into Actions that something broke. 2024.7.4 put Services back.

No it looks like it's an alexapy issue as mentioned in other threads see:
#2407 (comment)

@chrisvblemos
Copy link
Contributor

aiohttp.client_exceptions.InvalidUrlClientError: /errors/validateCaptcha

Somehow alexapy is attempting to send a post request to the url "/error/validateCaptcha", clearly a malformed url, which is why the exception is being raised by aiohttp. Could be an uncaught issue on how alexapy finds that URL, could be that amazon updated some page, a combination of these, etc.

@gtbdf1
Copy link

gtbdf1 commented Aug 8, 2024

@alandtse I believe everyone who has upgraded to 2024.8 is having this issue.

@chrisuk-web
Copy link

Same issue here. Fixed by rolling back to 2024.7.4

@Axsgranted
Copy link

having the same issue. rolled back but now i can't re-add the integration. 2FA stuff not working...

@doctorkb
Copy link

doctorkb commented Aug 8, 2024

I was having this issue, but managed to get it to work by deleting the integration entry, then adding a new one. When I added the new one, this was default:
image

(that is not my local address -- I have https enabled and a proper URL). I tried a bunch of permutations using my proper local address, but it finally worked when I made it this:
image

YMMV.

@Axsgranted
Copy link

Axsgranted commented Aug 8, 2024

I was having this issue, but managed to get it to work by deleting the integration entry, then adding a new one. When I added the new one, this was default: image

(that is not my local address -- I have https enabled and a proper URL). I tried a bunch of permutations using my proper local address, but it finally worked when I made it this: image

YMMV.

I deleted the integration. installed the previous version and did the 2FA setup. I use the string from the amazon site, verify the OTP and select the box and press submit. Each time I get "unknown error", and nothing in the logs.

Now Amazon thinks I've added 6 different devices.

@doctorkb
Copy link

doctorkb commented Aug 8, 2024

Don't install previous version of this integration. Use the newest release.

The previous one was giving me that unknown error business too.

@Axsgranted
Copy link

Don't install previous version of this integration. Use the newest release.

The previous one was giving me that unknown error business too.

That was the ticket, thanks!

@bfish2
Copy link

bfish2 commented Aug 8, 2024

also having issue with 2024.8 - Following for updates

@danielbrunt57
Copy link
Collaborator

Downgraded back to 2024.7.4 and it's working again, so something definitely broke this in 2024.8

It seems to me, that it may have to do with the unification of Services into Actions that something broke. 2024.7.4 put Services back.

Nope, nothing to do with services are now actions as that is just a code wrapper and it was working fine for me on the beta with actions from 8.0b0 up to and including 8.0b8. Then I got 8.0b9, installed it and 2024.8.0 was immediately presented which I installed and restarted and I now have this error:

aiohttp.client_exceptions.InvalidUrlClientError: /errors/validateCaptcha

In all likelihood, it comes down to aiohttp and alexapy and that is pretty much out of the scope of this integration.
alexpy is rather old and only has a couple of people looking at it.

I will continue investigating but I make no promises of it working again...

@expozeur
Copy link

expozeur commented Aug 8, 2024

Just install HA 2024.8 and all Updates of Alexa Media Player (AMP). Then change the manifest file. It should work then.

The files you are searching for an in the homeassistant docker file.

What if you aren't using Docker? I search for Manifest.JSON in StudioCode and find no file with that name.

@UlrichThiess
Copy link

Describe your installation.

@gtbdf1
Copy link

gtbdf1 commented Aug 8, 2024

Just install HA 2024.8 and all Updates of Alexa Media Player (AMP). Then change the manifest file. It should work then.
The files you are searching for an in the homeassistant docker file.

What if you aren't using Docker? I search for Manifest.JSON in StudioCode and find no file with that name.

Its probably easier to install the File Editor add on: https://github.com/home-assistant/addons/blob/master/configurator/README.md

Then open File Editor, and go to /homeassistant/custom_components/alexa_media/manifest.json

@snigehere
Copy link

snigehere commented Aug 8, 2024

Just install HA 2024.8 and all Updates of Alexa Media Player (AMP). Then change the manifest file. It should work then.
The files you are searching for an in the homeassistant docker file.

What if you aren't using Docker? I search for Manifest.JSON in StudioCode and find no file with that name.

@expozeur Its all lower case - eg manifest.json
Here is a picture from my studio code server
image

@zwolfinger
Copy link

zwolfinger commented Aug 8, 2024

Also experiencing this issue. I've tried uninstalling and reinstalling multiple times. Not sure about how/where to apply the patch mentioned above.

The patch was originally mentioned here

ssh to HA

docker exec -it $(docker ps -f name=homeassistant -q) bash to get to the container level of HA

cd /usr/local/lib/python3.12/site-packages/alexapy/

create the fix_cookies.patch file containing:

--- /tmp/alexalogin.py.orig
+++ /tmp/alexalogin.py.modified
@@ -1251,10 +1251,11 @@
                     # Strings are returned within quotations, strip them
                     else item["Value"][1:-1]
                 )
-                for name, value in item.items():
-                    if name in ["Name", "Value"]:
-                        continue
-                    raw_cookie[cookie_name][name] = f"{value}; Domain={domain}"
+                raw_cookie[cookie_name]["domain"] = domain
+                raw_cookie[cookie_name]["path"] = item["Path"]
+                raw_cookie[cookie_name]["secure"] = item["Secure"]
+                raw_cookie[cookie_name]["expires"] = item["Expires"]
+                raw_cookie[cookie_name]["httpOnly"] = item["HttpOnly"]                
                 # _LOGGER.debug("updating jar with cookie %s", raw_cookie)
                 self._session.cookie_jar.update_cookies(raw_cookie, URL(domain))
             _LOGGER.debug(

Then run:

apk --no-cache add patch
patch "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py" < "fix_cookies.patch"

The is the one that did it for me. I'm running HAOS and thought I could just run the patch in the terminal. Turns out that I HAD to run the patch in the homeassistant docker container. Once I ran the patch in the right place and restarted HA, all my Echos showed up again.

Thanks community!

@Scope666
Copy link

Scope666 commented Aug 8, 2024

Also experiencing this issue. I've tried uninstalling and reinstalling multiple times. Not sure about how/where to apply the patch mentioned above.

The patch was originally mentioned here
ssh to HA
docker exec -it $(docker ps -f name=homeassistant -q) bash to get to the container level of HA
cd /usr/local/lib/python3.12/site-packages/alexapy/
create the fix_cookies.patch file containing:

--- /tmp/alexalogin.py.orig
+++ /tmp/alexalogin.py.modified
@@ -1251,10 +1251,11 @@
                     # Strings are returned within quotations, strip them
                     else item["Value"][1:-1]
                 )
-                for name, value in item.items():
-                    if name in ["Name", "Value"]:
-                        continue
-                    raw_cookie[cookie_name][name] = f"{value}; Domain={domain}"
+                raw_cookie[cookie_name]["domain"] = domain
+                raw_cookie[cookie_name]["path"] = item["Path"]
+                raw_cookie[cookie_name]["secure"] = item["Secure"]
+                raw_cookie[cookie_name]["expires"] = item["Expires"]
+                raw_cookie[cookie_name]["httpOnly"] = item["HttpOnly"]                
                 # _LOGGER.debug("updating jar with cookie %s", raw_cookie)
                 self._session.cookie_jar.update_cookies(raw_cookie, URL(domain))
             _LOGGER.debug(

Then run:

apk --no-cache add patch
patch "/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py" < "fix_cookies.patch"

The is the one that did it for me. I'm running HAOS and thought I could just run the patch in the terminal. Turns out that I HAD to run the patch in the homeassistant docker container. Once I ran the patch in the right place and restarted HA, all my Echos showed up again.

Thanks community!

I believe this patch is only needed if your domain is NOT amazon.com

@meluvalli
Copy link

Modifying manifest.json requirements key like this solved it for me:

"requirements": ["alexapy>=1.28.2", "packaging>=20.3", "wrapt>=1.14.0"],

Thanks for the help.

THANK YOU, THANK YOU, THANK YOU! Fixed for me as well!

@tecnobrat
Copy link

This looks fixed in the newly released 4.12.7

@MidnightLink
Copy link

Confirming fixed as well

@alandtse alandtse closed this as completed Aug 8, 2024
@nicoema
Copy link

nicoema commented Aug 9, 2024

I got the Integration working. Byt no message to Echos.

@micium
Copy link

micium commented Aug 9, 2024 via email

@snigehere
Copy link

@micium as this seems to impact only some people I wonder if it's related to the service you call I am using notify.alex_media and it works OK.. are you using the old media_player.alexa_tts method?

@bmitchell76
Copy link

My echo's also stopped notifying, but I re-authenticated to Amazon and all is well again.

@micium
Copy link

micium commented Aug 9, 2024

@micium as this seems to impact only some people I wonder if it's related to the service you call I am using notify.alex_media and it works OK.. are you using the old media_player.alexa_tts method?

I'm using notify.alexa_media, also in the developer tool i got the same problem/msg

@baylf2000
Copy link

The update worked for me. I completely removed it from HACS, added the latest version, then completed the authorisation setup again, and it all works perfectly now. Thank you for the update!

@snigehere
Copy link

@micium as this seems to impact only some people I wonder if it's related to the service you call I am using notify.alex_media and it works OK.. are you using the old media_player.alexa_tts method?

I'm using notify.alexa_media, also in the developer tool i got the same problem/msg

This ticket seems to be similar #2053 - an issue with the tokens that needs to be refreshed.

@micium
Copy link

micium commented Aug 9, 2024

Refresh token mean remove and re-add the integration?

@snigehere
Copy link

Refresh token mean remove and re-add the integration?

I think others have reported success doing that

@micium
Copy link

micium commented Aug 9, 2024

@micium as this seems to impact only some people I wonder if it's related to the service you call I am using notify.alex_media and it works OK.. are you using the old media_player.alexa_tts method?

I'm using notify.alexa_media, also in the developer tool i got the same problem/msg

This ticket seems to be similar #2053 - an issue with the tokens that needs to be refreshed.

I confirm that after new authentication the problem is resolved. Many thanks

@lazyjai
Copy link

lazyjai commented Aug 9, 2024

Thank you everyone!

@ob1w4nken0b1
Copy link

ob1w4nken0b1 commented Aug 9, 2024

After a restart Echos work and notify for a couple of hours then it stops working and requires a restart to work again. No error messages or reauthentication requests from the integration.

Already tried reauthenticating a cuple times. No changes in behaviour

@micium
Copy link

micium commented Aug 9, 2024 via email

@fberbert
Copy link

Same here. 2024.8.1 not working

@hardwareadictos
Copy link

hardwareadictos commented Aug 18, 2024

So: What is recommended to do for now? I'm having the same issue and deleting and adding the integration to reconfigure it doesn't work. Also refreshing it doesn't. Only that worked for me was to roll back to last July HA update. Should we stick on this update for now?

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Aug 18, 2024

@hardwareadictos

  • Delete integration config entry
  • Delete /config/.storage/alexa_media.<your_email>.pickle file
    • AMP PR #2462 has been merged and v4.12.8 now includes its part in the new sequence to remove the cookiefile (pickle file in .storage) but alexapy merge request !380 needs to merge with a version bump and a new corresponding manifest.json (and another AMP version bump) for the remove cookiefile call to work.
  • Clear browser cookies
  • Restart HA
  • Verify your correct amazon account credentials
  • Verify Amazon 2SV (Two Step Verification) is enabled
  • Reinstall AMP integration - Note: Do not use private browsing mode!

@ABeumer525
Copy link

And add to this a password reset.

@hardwareadictos
Copy link

Seems that it also didn't work:

alexaapi.send_sequence((<alexapy.alexaapi.AlexaAPI object at 0x7f0acb1be000>, 'Alexa.Speak'), {'customer_id': '', 'textToSpeak': 'Alarma armada en modo nocturno', 'target': {'customerId': '', 'devices': [{'deviceSerialNumber': '', 'deviceTypeId': ''}]}, 'skillId': 'amzn1.ask.1p.saysomething', 'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)
alexaapi.send_tts((<alexapy.alexaapi.AlexaAPI object at 0x7f0acb1be000>, 'Alarma armada en modo nocturno'), {'customer_id': '', 'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)
alexaapi.run_behavior((<alexapy.alexaapi.AlexaAPI object at 0x7f0acb1be000>, {'@type': 'com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode', 'type': 'Alexa.Speak', 'operationPayload': {'deviceType': '', 'deviceSerialNumber': '', 'locale': 'es-es', 'customerId': '', 'textToSpeak': 'Modo diurno activad: ¡Buenos días!', 'target': {'customerId': '', 'devices': [{'deviceSerialNumber': '', 'deviceTypeId': ''}]}, 'skillId': 'amzn1.ask.1p.saysomething'}}), {'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)
alexaapi.send_sequence((<alexapy.alexaapi.AlexaAPI object at 0x7f0acb1be000>, 'Alexa.Speak'), {'customer_id': '', 'textToSpeak': 'Modo diurno activad: ¡Buenos días!', 'target': {'customerId': '', 'devices': [{'deviceSerialNumber': '', 'deviceTypeId': ''}]}, 'skillId': 'amzn1.ask.1p.saysomething', 'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)
alexaapi.send_tts((<alexapy.alexaapi.AlexaAPI object at 0x7f0acb1be000>, 'Modo diurno activad: ¡Buenos días!'), {'customer_id': '', 'queue_delay': 1.5}): An error occurred accessing AlexaAPI: An exception of type AlexapyLoginError occurred. Arguments: ('Login error detected; not contacting API',)

@spaggio80
Copy link

I think I've tried everything... As soon as I restart Home Assistant it seems to work (with some warnings), then after a few minutes everything freezes. Any hope of seeing this integration work?

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

No branches or pull requests