alexa_media_player: Reauthentication error

Describe the bug Reauthentication is impossible. Opening the Amazon website from the addon will show an error. It seems to be related to the cookiejar conversion between aiohttp and httpx. Only way to get it going again is removing the integration and setting it up again.

To Reproduce Steps to reproduce the behavior:

  1. Reauthenticate

Expected behavior


System details

  • Home-assistant (version): latest
  • 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 or HA startup): 3.10.15
  • alexapy (version from pip show alexapy or HA startup): 1.25.3 (authcaptureproxy 1.1.1)
  • Amazon 2FA is enabled (y/n). We will not debug login issues if unanswered: yes


Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 220, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 79, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 219, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/", line 137, in handle
    result = await result
  File "/config/custom_components/alexa_media/", line 1122, in wrapped
    return await cls.handler(request, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/authcaptureproxy/", line 387, in all_handler
    resp = await getattr(self.session, method)(
  File "/usr/local/lib/python3.9/site-packages/httpx/", line 1736, in get
    return await self.request(
  File "/usr/local/lib/python3.9/site-packages/httpx/", line 1500, in request
    request = self.build_request(
  File "/usr/local/lib/python3.9/site-packages/httpx/", line 351, in build_request
    return Request(
  File "/usr/local/lib/python3.9/site-packages/httpx/", line 1099, in __init__
  File "/usr/local/lib/python3.9/site-packages/httpx/", line 1792, in set_cookie_header
  File "/usr/local/lib/python3.9/http/", line 1367, in add_cookie_header
    attrs = self._cookie_attrs(cookies)
  File "/usr/local/lib/python3.9/http/", line 1326, in _cookie_attrs and version > 0):
TypeError: expected string or bytes-like object

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Commits related to this issue

Most upvoted comments

In case it helps someone.

I had the exact same problem you describe @larena1 (exact same logs and similar system details). I tried what you proposed and had, again, the exact same result Multiple cookies exist with name=session-id.

            cookies = self.login._session.cookie_jar.filter_cookies(
            cookies = {k: v.value for k, v in cookies.items()}
            self.proxy.session.cookies = cookies

While investigating I found out that I had a remnant of a precious version in my configuration.yaml I had completly forgotten about :

    - email: !secret amazon_user
      password: !secret amazon_password

I then did this:

  1. I removed this configuration ;
  2. I restarted HomeAssistant ;
  3. I removed the HACS integration ;
  4. I added the HACS integration again (3.10.15) ;
  5. I restarted HomeAssistant ;
  6. I added the integration and configured it following the standard way (didn’t touch any checkbox). It then worked on the first try.

@alandtse thank you for your work. I enjoy it a great deal.