alexa_media_player: failed to SignIn

Describe the bug After removing Alexa media Player due to several tests, for the issues the last days, I installed 4.12.5 today.

Unfortunately, it seems that there are configuration issues, depending on the selected amazon Domain.

I can start the login for DE Domain, I am also getting the tfa Page - but the Integration is showing a failure to login in the end of the process.

When I select COM Domain, everything is working and the Integration can login, but no devices we’re added.

To Reproduce

  1. Go to ‘…’
  2. Click on ‘…’
  3. Scroll down to ‘…’
  4. See error

Expected behavior

Should work independend of the selected amazon Domain.

Screenshots

System details

  • Home-assistant (version): 2024.8.0b4
  • alexa_media (version from const.py or HA startup): 4.12.5
  • alexapy (version from pip show alexapy or HA startup):
  • Amazon 2FA is enabled (y/n): y

Logs No Logs during Initial setup

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 56 (7 by maintainers)

Most upvoted comments

Two ways… Wait for an update, or:

Open /homeassistant/custom_components/alexa_media/manifest.json in File Editor Addin and change line 11 to: “requirements”: [“alexapy>=1.28.2”, “packaging>=20.3”, “wrapt>=1.14.0”],

Hello, same problem here in amazon.it

This was fixed in this release of the lib: https://gitlab.com/keatontaylor/alexapy/-/releases/v1.28.2 But the Alexa Media Player needs to update its dependecies to get this version…

Can confirm that editing the manifast.json to 1.28.2 is the correct workaround!

After changing the manifest and activating 2FA it worked without any problems using the DE- Domain.

This is an alexapy v1.28.1 issue. There’s already a solution by @chrisvblemos: https://github.com/alandtse/alexa_media_player/pull/2398#issuecomment-2272232708 https://gitlab.com/keatontaylor/alexapy/-/issues/32

alexalogin.py needs to be patched:

fix_cookies.patch

--- /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(

To use “patch” and the patch file above: apk --no-cache add patch patch “/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py” < “fix_cookies.patch”

To revert the patch: patch -R “/usr/local/lib/python3.12/site-packages/alexapy/alexalogin.py” < “fix_cookies.patch”

For v4.12.5, also edit manifest.json to: "requirements": ["alexapy>=1.28.1", "packaging>=20.3", "wrapt>=1.14.0"],

what about future updates of alexa media player? will it continue working?

Sorry, I seem to have misplaced my crystal ball…

Login to Amazon.com is working, Amazon.de is not working

Exact same problem for me. Domain related. .com works fine but I need amazon.co.uk.

For other users: this will work only on AMP 4.12.5. I tested this workaround in AMP 4.12.6, and this is not working

Works on 4.12.6 for me.

image Yes, the same here. Today installed the latest version of v4.12.5 to 2024.8.0b5 Alexa Media could not be logged in

I have the same issue on v4.12.6 (latest version at the time of writing)

@xhemp @EBobbbele Can you post the log?

Sure thing, let me know if this is the right one or you need anything else:

@xhemp

Either the patch wasn’t applied successfully or there is another issue. To make sure you are using the patch provided by jleinenbach, try to repeat the proccess but instead using the following patch file with additional logging:

--- /tmp/alexalogin.py.orig
+++ /tmp/alexalogin.py.modified
@@ -1251,10 +1251,12 @@
                     # 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.warning("Adding new cookie using alexapy's patch: %s", raw_cookie)
                 # _LOGGER.debug("updating jar with cookie %s", raw_cookie)
                 self._session.cookie_jar.update_cookies(raw_cookie, URL(domain))
             _LOGGER.debug(

Check your logs again afterwards. Multiple warnings should show up if the patch was applied:

_LOGGER.warning("Adding new cookie using alexapy's patch: %s", raw_cookie)

Note: this is a workaround and not an official patch. We need to wait for pull requests for alexapy and AMP for the proper fixes, making these patches unnecessary.

I have the same, tried to patch alexapy as well to no avail.

image Yes, the same here. Today installed the latest version of v4.12.5 to 2024.8.0b5 Alexa Media could not be logged in

I got it working too but looks like need to reauthenticate after every restart.

It would be good, If you could track this in a seperate issue and provide Log Files when this Happens again.

There were a couple of areas that had to be changed in the last days - so it is likely that Something with saving the cookies or similar dies mit Work…

Especially, when the Last Change in alexapy is related to partitioned cookies

Two ways… Wait for an update, or:

Open /homeassistant/custom_components/alexa_media/manifest.json in File Editor Addin and change line 11 to: “requirements”: [“alexapy>=1.28.2”, “packaging>=20.3”, “wrapt>=1.14.0”],

Worked for me…!! Thanks

OH-MY-GOD - it’s back!

Two ways… Wait for an update, or:

Open /homeassistant/custom_components/alexa_media/manifest.json in File Editor Addin and change line 11 to: “requirements”: [“alexapy>=1.28.2”, “packaging>=20.3”, “wrapt>=1.14.0”],

worked a treat! thank you!

Yes, I guess the code owner will update the dependency shortly. It was just fixed about 1 hour ago in alexapy, just be patient for some more minutes or couple of hours until the official dependency update. 😉