alandtse / alexa_media_player

This is a custom component to allow control of Amazon Alexa devices in Home Assistant using the unofficial Alexa API.
Apache License 2.0
1.5k stars 286 forks source link

Not able to Log In. Unknown Error Occurred #2393

Closed Techposts closed 2 months ago

Techposts commented 2 months ago

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

Enabled the 2FA. Added the Google Authenticator App. The integration is showing the OTP which matches the OTP on the Google Authenticator but when I click SUBMIT, it says Unknow Error occurred.

Tried Amaozn.com and Amazon.in

chrome_nD1PMEjFbN chrome_4ncBT5GfUR chrome_UEic2XZkDj chrome_sjbFghY6Py

Logs No logs generated for this as integration is failing. Alexa Media Player v4.12.4

(https://github.com/alandtse/alexa_media_player/wiki/FAQ#how-do-i-enable-debug-logging-for-the-component).

jeng37 commented 2 months ago

Exactly the same problem for me but for amazon.de

MichaelGier commented 2 months ago

for me the same problem. amazon.de

pkmaxl commented 2 months ago

I have the same problem. amazon.de

DrazorV commented 2 months ago

same

aptonline commented 2 months ago

Same issues with amazon.co.uk, logs show:

2024-08-03 09:28:30.310 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry email@email.com - amazon.co.uk for alexa_media
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/__init__.py", line 360, in async_setup_entry
if await test_login_status(hass, config_entry, login):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/__init__.py", line 1396, in test_login_status
async_create_persistent_notification(
TypeError: async_create() missing 1 required positional argument: 'hass'
robercy commented 2 months ago

Me too, on amazon.com!

jleinenbach commented 2 months ago

Same issues with amazon.co.uk, logs show:

2024-08-03 09:28:30.310 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry email@email.com - amazon.co.uk for alexa_media
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/__init__.py", line 360, in async_setup_entry
if await test_login_status(hass, config_entry, login):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/alexa_media/__init__.py", line 1396, in test_login_status
async_create_persistent_notification(
TypeError: async_create() missing 1 required positional argument: 'hass'

I have the same issue with amazon.de. I fixed this error message with ChatGPT support by adding "hass,", but that didn't fix this login problem:

async_create_persistent_notification(
    hass,
    message=message,
    title="Alexa Media Reauthentication Required",
    notification_id=f"alexa_media_{slugify(login.email)}{slugify(login.url[7:])}",
)
basti4874 commented 2 months ago

I have the same problem, tried all browsers, no success.

sharpe7852 commented 2 months ago

I have the same issue on v4.12.4

Teme-V commented 2 months ago

Same here, v4.12.4 Amazon.de https://github.com/alandtse/alexa_media_player/issues/2393#issuecomment-2266698672

c3p0vsr2d2 commented 2 months ago

Amazon.com. Same problem.

aguiducci commented 2 months ago

Same error with amazon.it and using nabu casa URL for external access and Alexa integration

yashijoe commented 2 months ago

Same here. Amazon.it Back to 4.12.1, still working.

Clamb94 commented 2 months ago

Same issue on amazon.de

compoundbow83 commented 2 months ago

Sames issue on amazon.de

ryebreadsalad commented 2 months ago

same issue on amazon.de when setting up the integration (no 2FA fields filled in)

Maorbz commented 2 months ago

Same here

M3XXstmk commented 2 months ago

Hello - Amazon.de. Same problem.

Mally2004uk commented 2 months ago

Same problem also. i have the problem when trying to add media player to home assistant

Obmawo commented 2 months ago

Same here. Amazon.de

aptonline commented 2 months ago

According to the PR from @danielbrunt57 this appears to have been fixed and just waiting for it to be merged so no more ‘me too’ needed 😀

jleinenbach commented 2 months ago

According to the PR from @danielbrunt57 this appears to have been fixed and just waiting for it to be merged so no more ‘me too’ needed 😀

After manually applying the fix according to the pull request, the 'Unknown Error Occurred' message was resolved. However, there is now a problem with the login process. Here is a detailed description of the steps and the issue:

  1. Entering OTP-key into the Integration: I enter the OTP-key into the integration, and it is accepted.

  2. Adding OTP-key to OTP App (backup): Additionally, I added the OTP-key to my OTP app, which ensures I have access to the necessary OTP for logging in on the Alexa page (not the Amazon page) with an App-OTP.

  3. Confirming the OTP in the Integration Dialog: Checkmark and done.

  4. Redirect to Alexa Login Page: I am redirected to the Alexa login page in my browser. Here, I need to log in again with a new App-OTP. I need to use my App as there's not another OTP provided by the integration.

  5. Integration Fails: Despite successfully logging in on the Alexa page, the integration ultimately indicates that the login was unsuccessful and fails.

EDIT: After multiple attempts, it finally worked. However, I had to use a new OTP code for step 4 from my Android OTP app. The integration prefilled the previously used OTP code from the earlier dialog, but it should have generated a new one for this step.

EDIT 2: I had to reauthenticate, now it always fails.

PrathikGopal commented 2 months ago

Same with amazon.in , reverted back to 4.12.1

c3p0vsr2d2 commented 2 months ago

EDIT 2: I had to reauthenticate, now it always fails.

jeng37 commented 2 months ago

Same here. Alexa-error

joeuser000 commented 2 months ago

Same issue. amazon us, AMP version 412.4. can't get past the OTP verification screen. Amazon 2fa setup. No log entries to facilitate debugging.

please ad

Nimri82 commented 2 months ago

same here

moseisleydk commented 2 months ago

Same her. I also dont rememeber that there are 2 "URL to access Home Assistant" fields - its that not new ...? Previously I always ended with and error 500 from the HA server....

chrisvblemos commented 2 months ago

According to the PR from @danielbrunt57 this appears to have been fixed and just waiting for it to be merged so no more ‘me too’ needed 😀

After manually applying the fix according to the pull request, the 'Unknown Error Occurred' message was resolved. However, there is now a problem with the login process. Here is a detailed description of the steps and the issue:

1. **Entering OTP-key into the Integration**: I enter the OTP-key into the integration, and it is accepted.

2. **Adding OTP-key to OTP App** (backup): Additionally, I added the OTP-key to my OTP app, which ensures I have access to the necessary OTP for logging in on the Alexa page (not the Amazon page) with an App-OTP.

3. **Confirming the OTP in the Integration Dialog**: Checkmark and done.

4. **Redirect to Alexa Login Page**: I am redirected to the Alexa login page in my browser. Here, I need to log in again with a new App-OTP. I need to use my App as there's not another OTP provided by the integration.

5. **Integration Fails**: Despite successfully logging in on the Alexa page, the integration ultimately indicates that the login was unsuccessful and fails.

EDIT: After multiple attempts, it finally worked. However, I had to use a new OTP code for step 4 from my Android OTP app. The integration prefilled the previously used OTP code from the earlier dialog, but it should have generated a new one for this step.

EDIT 2: I had to reauthenticate, now it always fails.

After fixing all issues with hass, hass_url and the errors related to the missing CONF_HASS_URL locally, I'm at the same place. I've been able to get to the Amazon screen when attempting to reauthenticate, but once I return from the Amazon page, the component reports a login error. No error messages on the log, but I know that the error happens when calling for alexapy's test_loggedin (which is returning False). All credentials like password, email, OTP, have been double checked.

I'm on HA version 2024.8.0b1 btw.

danielbrunt57 commented 2 months ago

The credentials used to sign into Alexa is your Amazon account so the OTP is for that account and you can use that OTP to complete login. The integration needs the 52 character secret code (QR code) to be able generate and supply the 6 digit OTP in future. For me, I use Bitwarden password app with a TOTP field and I can view and extract the 52 character code to give to AMP. Alternatively, if you can't view yours in your password manager &/or you did not record it, and rather than deleting OTP and configuring it again so you can save it, Amazon allows you to add additional apps. They're thinking password manager apps but in this case the pw manager "app" is AMP.
If you are unable to log in to Amazon with the user name, password and OTP that AMP is using, that's where your problem lies. Also, because it is a TOTP, you only have on average 15 seconds to complete the process of authenticating before the TOTP times out...sometimes it's 30 seconds, sometimes it's 1 second! Another reason I like using my primary TOTP and 52 character secret is I can see the countdown to a new code in Bitwarden. Also, since I only have one 52 character secret, I can simply enter it in AMP and when the login window prompts for the OTP which AMP prefilled, if it's changed in those few seconds, I can enter the newly created OTP from Bitwarden. Hope this helps clarify the process for everyone.

danielbrunt57 commented 2 months ago

I'm on HA version 2024.8.0b1 btw.

I haven't tried 2024.8.0 beta yet but I think it's time to since 2024.8.0 is right around corner plus I think I have most of the issues with AMP and 2024.7 worked out. Time to throw a new wrinkle into the mix!

chrisvblemos commented 2 months ago

The credentials used to sign into Alexa is your Amazon account so the OTP is for that account and you can use that OTP to complete login. The integration needs the 52 character secret code (QR code) to be able generate and supply the 6 digit OTP in future. For me, I use Bitwarden password app with a TOTP field and I can view and extract the 52 character code to give to AMP. Alternatively, if you can't view yours in your password manager &/or you did not record it, and rather than deleting OTP and configuring it again so you can save it, Amazon allows you to add additional apps. They're thinking password manager apps but in this case the pw manager "app" is AMP. If you are unable to log in to Amazon with the user name, password and OTP that AMP is using, that's where your problem lies. Also, because it is a TOTP, you only have on average 15 seconds to complete the process of authenticating before the TOTP times out...sometimes it's 30 seconds, sometimes it's 1 second! Another reason I like using my primary TOTP and 52 character secret is I can see the countdown to a new code in Bitwarden. Also, since I only have one 52 character secret, I can simply enter it in AMP and when the login window prompts for the OTP which AMP prefilled, if it's changed in those few seconds, I can enter the newly created OTP from Bitwarden. Hope this helps clarify the process for everyone.

Just to add to my report above, I'm using exactly the same setup as you with Bitwarden. I check the countdown, and if it has changed before submitting to the Amazon webpage, I replace it with the new one. Unfortunately, no luck so far.

Taking a look at alexapy logs:

2024-08-05 01:27:38.432 DEBUG (MainThread) [alexapy.alexalogin] Testing whether logged in to alexa.amazon.com.br
2024-08-05 01:27:38.432 DEBUG (MainThread) [alexapy.alexalogin] Cookies: None
2024-08-05 01:27:38.432 DEBUG (MainThread) [alexapy.alexalogin] Session Cookies:
2024-08-05 01:27:38.432 DEBUG (MainThread) [alexapy.alexalogin] Header: {"User-Agent": "AmazonWebView/Amazon Alexa/2.2.556530.0/iOS/16.6/iPhone", "Accept": "*/*", "Accept-Language": "*", "DNT": "1", "Upgrade-Insecure-Requests": "1"}
2024-08-05 01:27:38.432 DEBUG (MainThread) [alexapy.alexalogin] Attempting to register with amazon.com.br
2024-08-05 01:27:39.163 DEBUG (MainThread) [alexapy.alexalogin] auth response <ClientResponse(https://api.amazon.com.br/auth/register) [200 OK]>
2024-08-05 01:27:39.163 DEBUG (MainThread) [alexapy.alexalogin] Successfully registered <omitted> Alexa Media Player device with Amazon
2024-08-05 01:27:39.164 DEBUG (MainThread) [alexapy.alexalogin] Received registration data:
2024-08-05 01:27:39.164 DEBUG (MainThread) [alexapy.alexalogin] New access token(396) received which expires at 2024-08-05 02:27:39.164030 in 0:59:59.999990
2024-08-05 01:27:39.472 DEBUG (MainThread) [alexapy.alexalogin] capabilities response <ClientResponse(https://api.amazonalexa.com/v1/devices/@self/capabilities) [204 No Content]>
2024-08-05 01:27:39.821 DEBUG (MainThread) [alexapy.alexalogin] Exchange cookie json {'tokens': {'cookies': {'.amazon.com.br': [{'Path': '/', 'Secure': True, 'Value': '<omitted-for-this-comment>', 'Expires': '31 Jul 2044 04:27:39 GMT', 'HttpOnly': False, 'Name': 'session-id'}, {'Path': '/', 'Secure': True, 'Value': '<omitted-for-this-comment>', 'Expires': '31 Jul 2044 04:27:39 GMT', 'HttpOnly': False, 'Name': 'ubid-acbbr'}, {'Path': '/', 'Secure': True, 'Value': '"<omitted-for-this-comment>"', 'Expires': '31 Jul 2044 04:27:39 GMT', 'HttpOnly': False, 'Name': 'x-acbbr'}, {'Path': '/', 'Secure': True, 'Value': '"<omitted-for-this-comment>"', 'Expires': '6 Aug 2024 04:27:39 GMT', 'HttpOnly': True, 'Name': 'at-acbbr'}, {'Path': '/', 'Secure': True, 'Value': '"<omitted-for-this-comment>"', 'Expires': '6 Aug 2024 04:27:39 GMT', 'HttpOnly': True, 'Name': 'sess-at-acbbr'}]}}} 
2024-08-05 01:27:39.821 DEBUG (MainThread) [alexapy.alexalogin] 5 cookies successfully exchanged for refresh token for domain .amazon.com.br
2024-08-05 01:27:39.822 DEBUG (MainThread) [alexapy.alexalogin] Attempting to discover CSRF token
2024-08-05 01:27:40.075 DEBUG (MainThread) [alexapy.alexalogin] CSRF token not found from /spa/index.html
2024-08-05 01:27:40.352 DEBUG (MainThread) [alexapy.alexalogin] Unable to load page for csrf: <ClientResponse(https://alexa.amazon.com.br/api/language) [401 Unauthorized]>
2024-08-05 01:27:40.770 DEBUG (MainThread) [alexapy.alexalogin] Unable to load page for csrf: <ClientResponse(https://www.amazon.com.br/ap/signin?showRmrMe=1&openid.return_to=https://alexa.amazon.com.br/api/devices-v2/device?cached%3Dfalse&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.assoc_handle=amzn_dp_project_dee_br&openid.mode=checkid_setup&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.ns=http://specs.openid.net/auth/2.0&) [503 Service Unavailable]>
2024-08-05 01:27:40.988 DEBUG (MainThread) [alexapy.alexalogin] CSRF token not found from /templates/oobe/d-device-pick.handlebars
2024-08-05 01:27:41.138 DEBUG (MainThread) [alexapy.alexalogin] Unable to load page for csrf: <ClientResponse(https://alexa.amazon.com.br/api/strings) [401 Unauthorized]>
2024-08-05 01:27:41.138 DEBUG (MainThread) [alexapy.alexalogin] No csrf token found
2024-08-05 01:27:41.528 DEBUG (MainThread) [alexapy.alexalogin] GET: 
2024-08-05 01:27:41.684 DEBUG (MainThread) [alexapy.alexalogin] GET: 
2024-08-05 01:27:41.685 DEBUG (MainThread) [alexapy.alexalogin] Not logged in: An exception of type ContentTypeError occurred. Arguments:
danielbrunt57 commented 2 months ago

No idea right now what a CSRF token is. BTW, where do you find the alexapy logs?

chrisvblemos commented 2 months ago

No idea right now what a CSRF token is. BTW, where do you find the alexapy logs?

To enable alexapy logs, I added the following to my HA configuration.yaml:

logger:
  default: info
  logs:
    custom_components.alexa_media: debug
    alexapy: debug
danielbrunt57 commented 2 months ago

Duh! I was overthinking it! That'll definitely help me. Thanks.

jleinenbach commented 2 months ago

The dev branch of alexapy includes a 'fix: removes the new "partitioned" key from the saved cookie'. https://gitlab.com/keatontaylor/alexapy/-/commit/9aeb713cc0093a46f7cc824400774946431e3b15

jleinenbach commented 2 months ago

No idea right now what a CSRF token is.

ChatGPT tells me that Amazon changed the API: https://developer.amazon.com/de/docs/login-with-amazon/cross-site-request-forgery.html

chrisvblemos commented 2 months ago

Duh! I was overthinking it! That'll definitely help me. Thanks.

No problem!

New discovery. My domain is officially amazon.com.br, but attempting to use it results in the errors as described above. When switching to "amazon.com", the default one, it works. This is weird, since there is a check inside alexapy that "succeeds" and writes this funny log:

2024-08-05 02:58:07.181 DEBUG (MainThread) [alexapy.alexalogin] Domain amazon.com matches reported account domain: https://www.amazon.com.br

Clearly, even though it has worked, some weird stuff might happen in the future with this mismatch. I've added an issue to alexapy repo describing this behavior. At the same time, I don't think this is directly related to the issue described in here, although I'm pretty sure something is related to the domains and maybe to alexapy and the new home assistant version

If you want to, you can check my fork to try and replicate. I've respectfully stolen some of your edits.

jleinenbach commented 2 months ago

New discovery. My domain is officially amazon.com.br, but attempting to use it results in the errors as described above. When switching to "amazon.com", the default one, it works.

Same here (default amazon.com instead of amazon.de). I can see all my entities again and it works after a reboot of HA, too.

(Note: The only thing I did is to manually integrate Daniel's commits #2398 and update alexapy to the dev version.)

jleinenbach commented 2 months ago

Based on the observed log message and standard security practices, it is possible that Amazon now redirects regional domains to the primary amazon.com domain to simplify and strengthen CSRF protection and authentication processes.

jleinenbach commented 2 months ago

Oh, the integration still loads after a reboot, the devices/entitites are still visible, but unavailable:

image

danielbrunt57 commented 2 months ago

CSRF: https://en.wikipedia.org/wiki/Cross-site_request_forgery CSRF token validation: https://portswigger.net/web-security/csrf/bypassing-token-validation

I've enabled alexpy debug and I see that I currently have a CSRF token...

image

My alexapy log is quite different. I'm failing to register capabilities, I have an existing CSRF token, and my login works:

2024-08-05 00:59:06.652 DEBUG (MainThread) [custom_components.alexa_media] Loaded alexapy==1.28.1
2024-08-05 00:59:06.742 DEBUG (MainThread) [alexapy.alexalogin] Creating TOTP for R************************************************J5A
2024-08-05 00:59:06.743 DEBUG (MainThread) [alexapy.alexalogin] Generating OTP 408040
2024-08-05 00:59:06.744 DEBUG (MainThread) [alexapy.alexalogin] Login created for d****l@b******a - amazon.com
2024-08-05 00:59:06.744 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.d****l@b******a.pickle
2024-08-05 00:59:06.746 DEBUG (MainThread) [alexapy.alexalogin] Trying to load cookie from file /config/.storage/alexa_media.d****l@b******a.pickle
2024-08-05 00:59:06.904 DEBUG (MainThread) [alexapy.alexalogin] Trying to load aiohttpCookieJar to session
2024-08-05 00:59:06.931 DEBUG (MainThread) [alexapy.alexalogin] Loaded 10 cookies
2024-08-05 00:59:06.931 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/alexa_media.d****l@b******a.pickle
2024-08-05 00:59:06.932 DEBUG (MainThread) [alexapy.alexalogin] Using cookies to log in
2024-08-05 00:59:06.933 DEBUG (MainThread) [alexapy.alexalogin] Attempting to register with amazon.com
2024-08-05 00:59:07.390 DEBUG (MainThread) [alexapy.alexalogin] auth response <ClientResponse(https://api.amazon.com/auth/register) [401 Unauthorized]>
2024-08-05 00:59:07.390 DEBUG (MainThread) [alexapy.alexalogin] Unable to register with ['amazon.com']
2024-08-05 00:59:07.505 DEBUG (MainThread) [alexapy.alexalogin] capabilities response <ClientResponse(https://api.amazonalexa.com/v1/devices/@self/capabilities) [403 Forbidden]>
2024-08-05 00:59:07.506 DEBUG (MainThread) [alexapy.alexalogin] Failed to register capabilities
2024-08-05 00:59:07.735 DEBUG (MainThread) [alexapy.alexalogin] 5 cookies successfully exchanged for refresh token for domain .amazon.com
2024-08-05 00:59:07.741 DEBUG (MainThread) [alexapy.alexalogin] CSRF already exists; no need to discover
2024-08-05 00:59:07.937 DEBUG (MainThread) [alexapy.alexalogin] GET:
2024-08-05 00:59:07.938 DEBUG (MainThread) [alexapy.alexalogin] Logged in as d****l@b******a to amazon.com with id: A*U*9*D*N*3*5*
2024-08-05 00:59:09.119 DEBUG (MainThread) [alexapy.alexalogin] Domain amazon.com matches reported account domain: https://www.amazon.com
2024-08-05 00:59:09.130 DEBUG (MainThread) [alexapy.alexalogin] Login confirmed for d****l@b******a - amazon.com; saving cookie to /config/.storage/alexa_media.d****l@b******a.pickle
2024-08-05 00:59:09.170 DEBUG (MainThread) [custom_components.alexa_media] d****l@b******a: HTTP2 created: <alexapy.alexahttp2.HTTP2EchoClient object at 0xffff6a8b0680>
2024-08-05 00:59:09.184 DEBUG (MainThread) [alexapy.alexahttp2] Starting message parsing loop.
jleinenbach commented 2 months ago

Interesting. Although I get the mismatch warning, I don't get a forbidden message.

2024-08-05 10:23:36.620 DEBUG (MainThread) [alexapy.alexalogin] Creating TOTP for Y************************************************26A
2024-08-05 10:23:36.620 DEBUG (MainThread) [alexapy.alexalogin] Generating OTP 732734
2024-08-05 10:23:36.620 DEBUG (MainThread) [alexapy.alexalogin] Login created for j*************h@g*******m - amazon.com
2024-08-05 10:23:36.620 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.j*************h@g*******m.pickle
2024-08-05 10:23:36.620 DEBUG (MainThread) [alexapy.alexalogin] Trying to load cookie from file /config/.storage/alexa_media.j*************h@g*******m.pickle
2024-08-05 10:23:36.624 DEBUG (MainThread) [alexapy.alexalogin] Trying to load aiohttpCookieJar to session
2024-08-05 10:23:36.625 DEBUG (MainThread) [alexapy.alexalogin] Loaded 11 cookies
2024-08-05 10:23:36.626 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/alexa_media.j*************h@g*******m.pickle
2024-08-05 10:23:36.626 DEBUG (MainThread) [alexapy.alexalogin] Using cookies to log in
2024-08-05 10:23:36.626 DEBUG (MainThread) [alexapy.alexalogin] Attempting to register with amazon.com
2024-08-05 10:23:37.285 DEBUG (MainThread) [alexapy.alexalogin] auth response <ClientResponse(https://api.amazon.com/auth/register) [200 OK]> [...]
2024-08-05 10:23:37.285 DEBUG (MainThread) [alexapy.alexalogin] Successfully registered Jens's 4th Alexa Media Player device with Amazon
2024-08-05 10:23:37.285 DEBUG (MainThread) [alexapy.alexalogin] New access token(353) received which expires at 2024-08-05 11:23:37.285468 in 0:59:59.999987
2024-08-05 10:23:37.804 DEBUG (MainThread) [alexapy.alexalogin] capabilities response <ClientResponse(https://api.amazonalexa.com/v1/devices/@self/capabilities) [204 No Content]> [...]
2024-08-05 10:23:38.243 DEBUG (MainThread) [alexapy.alexalogin] 5 cookies successfully exchanged for refresh token for domain .amazon.com
2024-08-05 10:23:38.243 DEBUG (MainThread) [alexapy.alexalogin] CSRF already exists; no need to discover
2024-08-05 10:23:38.645 DEBUG (MainThread) [alexapy.alexalogin] GET: 
https://alexa.amazon.com/api/bootstrap returned 200:OK with response [...]
2024-08-05 10:23:38.645 DEBUG (MainThread) [alexapy.alexalogin] Logged in as [...] to amazon.com with id: A4MPYH3GO1NU6
2024-08-05 10:23:39.023 WARNING (MainThread) [alexapy.alexalogin] Domain amazon.com does not match reported account domain https://www.amazon.de; functionality is not likely to work, please fix
2024-08-05 10:23:39.024 DEBUG (MainThread) [alexapy.alexalogin] Login confirmed for j*************h@g*******m - amazon.com; saving cookie to /config/.storage/alexa_media.j*************h@g*******m.pickle
2024-08-05 10:23:39.040 DEBUG (MainThread) [alexapy.alexahttp2] Starting message parsing loop.
2024-08-05 10:23:39.040 DEBUG (MainThread) [alexapy.alexahttp2] Connecting to https://alexa.na.gateway.devices.a2z.com/v20160207/directives with {'method': 'GET', 'path': '/v20160207/directives', 'authority': 'alexa.na.gateway.devices.a2z.com', 'scheme': 'https', 'authorization': [...]
2024-08-05 10:23:39.040 DEBUG (MainThread) [alexapy.alexahttp2] Preparing ping to https://alexa.na.gateway.devices.a2z.com/ping
2024-08-05 10:23:39.256 DEBUG (MainThread) [alexapy.alexaapi] j*************h@g*******m: static GET: https://alexa.amazon.com/api/phoenix returned 200:OK:application/json
2024-08-05 10:23:39.256 DEBUG (MainThread) [alexapy.alexaapi] j*************h@g*******m: get_network_details response: {'locationDetails': {'locationDetails': {'Default_Location': {'locationId': 'Default_Location', 'amazonBridgeDetails': {'amazonBridgeDetails': {}}, 'applianceGroups': {'applianceGroups': {}}}}}, 'version': '1.0', 'relations': []}
mgmtotorsperformance commented 2 months ago

same on amazon.co.uk

jleinenbach commented 2 months ago

Maybe this is a hint: 'x-amzn-alt-domain': 'https://alexa.amazon.de/logout'

2024-08-05 11:36:19.787 DEBUG (MainThread) [alexapy.alexalogin] 5 cookies successfully exchanged for refresh token for domain .amazon.com
2024-08-05 11:36:19.787 DEBUG (MainThread) [alexapy.alexalogin] CSRF already exists; no need to discover
2024-08-05 11:36:20.104 DEBUG (MainThread) [alexapy.alexalogin] GET: 
https://alexa.amazon.com/api/bootstrap returned 200:OK with response <CIMultiDictProxy('Content-Type': 'application/json', 'Content-Length': '181', 'Connection': 'keep-alive', 'Server': 'Server', 'Date': 'Mon, 05 Aug 2024 09:36:20 GMT', 'Vary': 'Content-Type,Accept-Encoding,User-Agent', 'x-amz-rid': 'S4W04AV3JDHK0CVPSWG2', 'x-amzn-ActionTrace': 'amzn1.tr.3c62a059-2eae-11e6-8dc8-0a59c57a0200.1225.9z#7EX.H0nbsN', 'x-amzn-RequestId': 'S4W04AV3JDHK0CVPSWG2', 'x-amzn-alt-domain': 'https://alexa.amazon.de/logout', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 64c8688da1fd73389eb91af90ae83792.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'FRA56-P8', 'X-Amz-Cf-Id': 'TBVy4AtbISmBrhozN9LAK19BzQ0XE_b17b44nWHZs96GQApBna-WZw==')>
2024-08-05 11:36:20.104 DEBUG (MainThread) [alexapy.alexalogin] Logged in as j*************h@g*******m to amazon.com with id: A4MPYH2GO0NU4
2024-08-05 11:36:20.511 WARNING (MainThread) [alexapy.alexalogin] Domain amazon.com does not match reported account domain https://www.amazon.de; functionality is not likely to work, please fix
danielbrunt57 commented 2 months ago

Just in... I'm up and running fine on 2024.8.0b2 with these changes & alexapy 1.28.1. I upgraded 2024.7.4 to 2024.8.0b1 & AMP failed to load - partitioned cookie despite my having alexapy 1.28.1 Waited for database upgrade to complete Removed the config entry & the pickle file & restarted Re-added the integration and it loaded fine (always does at that point) Then I spotted 8.0b2 was released 8 minutes ago - installed, restarted. AMP complained about hass parameter missing in __init__py in create persistent notification line 1326 - added it, restarted and no errors. I've updated the PR with that change...

danielbrunt57 commented 2 months ago

@Techposts Please provide your alexa_media debug logs...

danielbrunt57 commented 2 months ago

Current alexapy log:

2024-08-05 04:02:14.839 DEBUG (MainThread) [custom_components.alexa_media] Loaded alexapy==1.28.1
2024-08-05 04:02:14.863 DEBUG (MainThread) [alexapy.alexalogin] Creating TOTP for R************************************************J5A
2024-08-05 04:02:14.863 DEBUG (MainThread) [alexapy.alexalogin] Generating OTP 478599
2024-08-05 04:02:14.864 DEBUG (MainThread) [alexapy.alexalogin] Login created for d*****@*****a - amazon.com
2024-08-05 04:02:14.864 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/.storage/alexa_media.d*****@*****a.pickle
2024-08-05 04:02:14.865 DEBUG (MainThread) [alexapy.alexalogin] Trying to load cookie from file /config/.storage/alexa_media.d*****@*****a.pickle
2024-08-05 04:02:14.885 DEBUG (MainThread) [alexapy.alexalogin] Pickled cookie loaded: <class 'collections.defaultdict'> defaultdict(<class 'http.cookies.SimpleCookie'>, {('amazon.com', '/ap'): <SimpleCookie: >, ('amazon.com', ''): <SimpleCookie: at-main='Atza|IwEBIO3hPmpVlkdHtY2JWO99QaQ-iDq5naQ46HPJFdLg5cGrl2TyvYy101Yi7R--S4WSNrFmus70YoMpysnzmU98fsDqHMaLg4KWTTKMzIPyYMcd6NcT2lJwBuD1Zuc_0VI7CalcwrMrWcESNyjikTcGrJ4tZ_8zTYeNZ_PH0yxag8ISZTPgUNJyxProuEpNSRefku1Xxa1eZK-QOmYEXYZCpuDy9CKgtYoW3LuW35TrDZPlNg' csrf='494577323' lc-main='en_US' sess-at-main='4SvHd2OPonKl2hPR7ZMUp6xyN69TChJYvDJeD2Nq+pA=' session-id='139-3005269-4845447' session-id-time='2353574560l' session-token='Wz7DwO3orb4DcWODoxIAz/oufqHnYUBUbwsnTYuYMEGr3rvvntTB0kl3vNiWhsvimv1ETdpr16HEgGY3kZzadgg7RjM+avMjO6VBYUpdfskEAjnJsxCOJ71jbj6WgNDljR6yKxrJkhAb/il4yNhLh2cX6D0YD7KZPqV8a5nXrJScKClaUGiVieEtueAqXjf4jTxXsZqzv7ZFvoNLE6ylYVNd46NYiWr1I43Ekg/9c7+FZE/uGxc8BP4epfPb+xFhV4M3XeZV8GlRu7FVNAZNN4W9ki9yFPI7rijScnyhNfnO8a8eVTDobWLx0UjJ/WuX3cLMurIpwIttagnaLgnhsXlWU4dJYgDG0USMYyBc16jcHLocf6b/6g==' ubid-main='131-8666979-2828220' x-main='a0kUZqPLMQWhzjJmLO8EeDnpkuWh3a@5'>, ('', ''): <SimpleCookie: >, ('com', ''): <SimpleCookie: >, ('com', '/ap'): <SimpleCookie: >, ('com', '/ap/signin'): <SimpleCookie: >, ('com', '/ap/signin/139-3005269-4845447'): <SimpleCookie: >, ('amazon.com', '/ap/signin'): <SimpleCookie: >, ('amazon.com', '/ap/signin/139-3005269-4845447'): <SimpleCookie: >, ('www.amazon.com', ''): <SimpleCookie: >, ('www.amazon.com', '/ap'): <SimpleCookie: >, ('www.amazon.com', '/ap/signin'): <SimpleCookie: >, ('www.amazon.com', '/ap/signin/139-3005269-4845447'): <SimpleCookie: >, ('com', '/ap/maplanding'): <SimpleCookie: >, ('amazon.com', '/ap/maplanding'): <SimpleCookie: >, ('www.amazon.com', '/ap/maplanding'): <SimpleCookie: >, ('https', ''): <SimpleCookie: >, ('https', '/'): <SimpleCookie: >, ('https', '//amazon.com'): <SimpleCookie: >, ('com', '/auth'): <SimpleCookie: >, ('com', '/auth/register'): <SimpleCookie: >, ('amazon.com', '/auth'): <SimpleCookie: >, ('amazon.com', '/auth/register'): <SimpleCookie: >, ('api.amazon.com', ''): <SimpleCookie: >, ('api.amazon.com', '/auth'): <SimpleCookie: >, ('api.amazon.com', '/auth/register'): <SimpleCookie: >, ('com', '/v1'): <SimpleCookie: >, ('com', '/v1/devices'): <SimpleCookie: >, ('com', '/v1/devices/@self'): <SimpleCookie: >, ('com', '/v1/devices/@self/capabilities'): <SimpleCookie: >, ('amazonalexa.com', ''): <SimpleCookie: >, ('amazonalexa.com', '/v1'): <SimpleCookie: >, ('amazonalexa.com', '/v1/devices'): <SimpleCookie: >, ('amazonalexa.com', '/v1/devices/@self'): <SimpleCookie: >, ('amazonalexa.com', '/v1/devices/@self/capabilities'): <SimpleCookie: >, ('api.amazonalexa.com', ''): <SimpleCookie: >, ('api.amazonalexa.com', '/v1'): <SimpleCookie: >, ('api.amazonalexa.com', '/v1/devices'): <SimpleCookie: >, ('api.amazonalexa.com', '/v1/devices/@self'): <SimpleCookie: >, ('api.amazonalexa.com', '/v1/devices/@self/capabilities'): <SimpleCookie: >, ('com', '/ap/exchangetoken'): <SimpleCookie: >, ('com', '/ap/exchangetoken/cookies'): <SimpleCookie: >, ('amazon.com', '/ap/exchangetoken'): <SimpleCookie: >, ('amazon.com', '/ap/exchangetoken/cookies'): <SimpleCookie: >, ('www.amazon.com', '/ap/exchangetoken'): <SimpleCookie: >, ('www.amazon.com', '/ap/exchangetoken/cookies'): <SimpleCookie: >, ('', '/; Domain=.amazon.com'): <SimpleCookie: at-main='Atza|IwEBIKdsoME8LAlziGgVOqEo7rCnh-s7bxP4s2Trb4WCWYSH9tTpHpNYeLuDFRfauX5hsujfUlifUdKjC518EbRbeS2RCrUBOnkFb3s7g-eeU2EyuvvImeDgWCdr3yE0DA6JNOTydYItmeqjtqN699UaymK8dcG-CYSnFNzjLUFKILbJbv3oNdIdmUds6r_1P6WLepRhwtPiNAb16P3WjriHXdqWMkceA5HZ9TcWzsJGtNlpE5gk6W_vgaYDNkVY9oudk1bqh5bJAmsEh0lkJgXOuOkDj874Qj3TXJFJc8pjvUHbAqGQUNdDMCeHvTPA8Vi3_dgBjsqTaW1rffoSaqz7k3_6C74hJK_SSf23GnFOY3WgEGgxkHqdS8uTcqj3VqdsoEqAeGBMETfAS5xZd5WFVkDd' sess-at-main='ViwvUZuUk8TEnmKJOyIOKpP0yRTvuxM1pomo+9SGCNw=' session-id='139-3005269-4845447' ubid-main='131-8666979-2828220' x-main='lAHY8Idurso@85pvvzynn3EdgJ0tcVYS'>, ('com', '/'): <SimpleCookie: >, ('amazon.com', '/'): <SimpleCookie: >, ('com', '/spa'): <SimpleCookie: >, ('com', '/spa/index.html'): <SimpleCookie: >, ('amazon.com', '/spa'): <SimpleCookie: >, ('amazon.com', '/spa/index.html'): <SimpleCookie: >, ('alexa.amazon.com', ''): <SimpleCookie: >, ('alexa.amazon.com', '/spa'): <SimpleCookie: >, ('alexa.amazon.com', '/spa/index.html'): <SimpleCookie: >, ('com', '/api'): <SimpleCookie: >, ('com', '/api/language'): <SimpleCookie: >, ('amazon.com', '/api'): <SimpleCookie: >, ('amazon.com', '/api/language'): <SimpleCookie: >, ('alexa.amazon.com', '/api'): <SimpleCookie: >, ('alexa.amazon.com', '/api/language'): <SimpleCookie: >, ('com', '/api/bootstrap'): <SimpleCookie: >, ('amazon.com', '/api/bootstrap'): <SimpleCookie: >, ('alexa.amazon.com', '/api/bootstrap'): <SimpleCookie: >, ('com', '/api/users'): <SimpleCookie: >, ('com', '/api/users/me'): <SimpleCookie: >, ('amazon.com', '/api/users'): <SimpleCookie: >, ('amazon.com', '/api/users/me'): <SimpleCookie: >, ('alexa.amazon.com', '/api/users'): <SimpleCookie: >, ('alexa.amazon.com', '/api/users/me'): <SimpleCookie: >})
2024-08-05 04:02:14.887 DEBUG (MainThread) [alexapy.alexalogin] Trying to load aiohttpCookieJar to session
2024-08-05 04:02:14.889 DEBUG (MainThread) [alexapy.alexalogin] Loaded 9 cookies
2024-08-05 04:02:14.890 DEBUG (MainThread) [alexapy.alexalogin] Searching for cookies from /config/alexa_media.d*****@*****a.pickle
2024-08-05 04:02:14.890 DEBUG (MainThread) [alexapy.alexalogin] Using cookies to log in
2024-08-05 04:02:14.890 DEBUG (MainThread) [alexapy.alexalogin] Testing whether logged in to alexa.amazon.com
2024-08-05 04:02:14.890 DEBUG (MainThread) [alexapy.alexalogin] Cookies: Set-Cookie: at-main=Atza|IwEBIO3hPmpVlkdHtY2JWO99QaQ-iDq5naQ46HPJFdLg5cGrl2TyvYy101Yi7R--S4WSNrFmus70YoMpysnzmU98fsDqHMaLg4KWTTKMzIPyYMcd6NcT2lJwBuD1Zuc_0VI7CalcwrMrWcESNyjikTcGrJ4tZ_8zTYeNZ_PH0yxag8ISZTPgUNJyxProuEpNSRefku1Xxa1eZK-QOmYEXYZCpuDy9CKgtYoW3LuW35TrDZPlNg
2024-08-05 04:02:14.890 DEBUG (MainThread) [alexapy.alexalogin] Session Cookies:
2024-08-05 04:02:14.891 DEBUG (MainThread) [alexapy.alexalogin] Header: {"User-Agent": "AmazonWebView/Amazon Alexa/2.2.556530.0/iOS/16.6/iPhone", "Accept": "*/*", "Accept-Language": "*", "DNT": "1", "Upgrade-Insecure-Requests": "1"}
2024-08-05 04:02:14.892 DEBUG (MainThread) [alexapy.alexalogin] Attempting to register with amazon.com
2024-08-05 04:02:15.479 DEBUG (MainThread) [alexapy.alexalogin] auth response <ClientResponse(https://api.amazon.com/auth/register) [200 OK]>
2024-08-05 04:02:15.479 DEBUG (MainThread) [alexapy.alexalogin] Successfully registered Daniel's Alexa Media Player device with Amazon
2024-08-05 04:02:15.479 DEBUG (MainThread) [alexapy.alexalogin] Received registration data:
2024-08-05 04:02:15.479 DEBUG (MainThread) [alexapy.alexalogin] New access token(353) received which expires at 2024-08-05 05:02:15.479930 in 0:59:59.999971
2024-08-05 04:02:15.717 DEBUG (MainThread) [alexapy.alexalogin] capabilities response <ClientResponse(https://api.amazonalexa.com/v1/devices/@self/capabilities) [204 No Content]>
2024-08-05 04:02:16.039 DEBUG (MainThread) [alexapy.alexalogin] Exchange cookie json {'tokens': {'cookies': {'.amazon.com': [{'Path': '/', 'Secure': True, 'Value': '139-3005269-4845447', 'Expires': '31 Jul 2044 11:02:15 GMT', 'HttpOnly': False, 'Name': 'session-id'}, {'Path': '/', 'Secure': True, 'Value': '131-8666979-2828220', 'Expires': '31 Jul 2044 11:02:15 GMT', 'HttpOnly': False, 'Name': 'ubid-main'}, {'Path': '/', 'Secure': True, 'Value': '"Y86fbE6?0KQcm3Svw@ATMhuVB@J1xaLa"', 'Expires': '31 Jul 2044 11:02:15 GMT', 'HttpOnly': False, 'Name': 'x-main'}, {'Path': '/', 'Secure': True, 'Value': '"Atza|IwEBIA8qjxJhbHOgqyvVqBQ-JQ1OSgLol71f0GUsdsSnIZ4Eotd8ZvGgPpWg5U2qh0OPPdfF0Qv9vv3Qqx8LohufoWzmfKA-P6EL-9CsX80Crb0kjxXnwdj56PnxwQSeERxK7Akpdu3q1anFf60nNS-zBQSUIZUtdNrlfDYC_tG508ybYEID77seXapmgtZ_PmA4hWNSea1zExp5aYo7evhSEsqhJfOHLDJQoBAhVbofeVNJWcdBip2RPXYwc3PNuI48Dd5noOv6hSqW98E_45cBu-CytOiJT0D4RrNobYOCBY7Pplye3K-G8SuxY5RJ7QNT_9tZDfC3IPnSbisCn8kz7dZCoOVDqj3ewAhFezgc5x2SFrSz3icc7VWC0ims4FJ4-Ee-8ypSz5pP94npU06IGGaw"', 'Expires': '6 Aug 2024 11:02:15 GMT', 'HttpOnly': True, 'Name': 'at-main'}, {'Path': '/', 'Secure': True, 'Value': '"XKb5IJkfLyOhhS737BbVjGnexYTE0TN1XVLsrsd9pI0="', 'Expires': '6 Aug 2024 11:02:15 GMT', 'HttpOnly': True, 'Name': 'sess-at-main'}]}}}
2024-08-05 04:02:16.040 DEBUG (MainThread) [alexapy.alexalogin] 5 cookies successfully exchanged for refresh token for domain .amazon.com
2024-08-05 04:02:16.041 DEBUG (MainThread) [alexapy.alexalogin] CSRF already exists; no need to discover
2024-08-05 04:02:17.290 DEBUG (MainThread) [alexapy.alexalogin] GET:
2024-08-05 04:02:17.290 DEBUG (MainThread) [alexapy.alexalogin] Logged in as d*****@*****a to amazon.com with id: A1UZ93DGNU3F5L
2024-08-05 04:02:17.756 DEBUG (MainThread) [alexapy.alexalogin] Domain amazon.com matches reported account domain: https://www.amazon.com
2024-08-05 04:02:17.757 DEBUG (MainThread) [alexapy.alexalogin] Saving cookie to /config/.storage/alexa_media.d*****@*****a.pickle
2024-08-05 04:02:17.784 DEBUG (MainThread) [alexapy.alexalogin] Session Cookies:
2024-08-05 04:02:17.784 DEBUG (MainThread) [alexapy.alexalogin] Login confirmed for d*****@*****a - amazon.com; saving cookie to /config/.storage/alexa_media.d*****@*****a.pickle
2024-08-05 04:02:17.784 DEBUG (MainThread) [alexapy.alexalogin] Saving cookie to /config/.storage/alexa_media.d*****@*****a.pickle
2024-08-05 04:02:17.791 DEBUG (MainThread) [alexapy.alexalogin] Session Cookies:
2024-08-05 04:02:17.817 DEBUG (MainThread) [custom_components.alexa_media] d****l@b******a: HTTP2 created: <alexapy.alexahttp2.HTTP2EchoClient object at 0xffff4df17b30>
2024-08-05 04:02:17.827 DEBUG (MainThread) [alexapy.alexahttp2] Starting message parsing loop.
joeuser000 commented 2 months ago

HA Core: 2024.7.3 Frontend: 20240710.0 Alexa_Media_Player v4.12.4

"Unknown Error" when trying to install using OTP saw this is the logs after attempt.

File "/usr/local/lib/python3.12/site-packages/yarl/_url.py", line 179, in __new__ raise TypeError("Constructor parameter should be str") TypeError: Constructor parameter should be str

alexa_media_install_fail

Sohnkarlsruhes commented 2 months ago

My workaround, install with hacs Version 4.12.0 and login, After successfull login, Update to current version