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.44k stars 275 forks source link

404 error when setting up alexa intergration #2318

Closed f3bandit closed 1 month ago

f3bandit commented 1 month 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 404 error when setting up alexa intergration

404 error when setting up alexa intergration under services and devices. get a 404 error after clicking open website during final step of setup process. To Reproduce

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

Expected behavior

alexa integration to work Screenshots

System details

Additional context

danielbrunt57 commented 1 month ago

Please try adding custom repository https://github.com/danielbrunt57/alexa_media_player, install latest version (4.10.3.1) and report results.

f3bandit commented 1 month ago

Please try adding custom repository https://github.com/danielbrunt57/alexa_media_player, install latest version (4.10.3.1) and report results.

nope 404 error

f3bandit commented 1 month ago

idk if any of this is useful logs: Logger: homeassistant.helpers.frame Source: helpers/frame.py:184 First occurred: 5:06:37 PM (4 occurrences) Last logged: 5:06:44 PM

Detected that custom integration 'hacs' calls hass.http.register_static_path which is deprecated because it does blocking I/O in the event loop, instead call await hass.http.async_register_static_paths([StaticPathConfig("/hacsfiles/frontend", "/config/custom_components/hacs/hacs_frontend", False)]); This function will be removed in 2025.7 at custom_components/hacs/frontend.py, line 54: hass.http.register_static_path(f"{URL_BASE}/frontend", locate_dir(), cache_headers=False), please create a bug report at https://github.com/hacs/integration/issues Detected that custom integration 'hacs' calls hass.http.register_static_path which is deprecated because it does blocking I/O in the event loop, instead call await hass.http.async_register_static_paths([StaticPathConfig("/hacsfiles/iconset.js", "/config/custom_components/hacs/iconset.js", True)]); This function will be removed in 2025.7 at custom_components/hacs/frontend.py, line 57: hass.http.register_static_path(, please create a bug report at https://github.com/hacs/integration/issues Detected that custom integration 'hacs' accesses hass.components.frontend. This is deprecated and will stop working in Home Assistant 2024.9, it should be updated to import functions used from frontend directly at custom_components/hacs/frontend.py, line 68: hass.components.frontend.async_register_built_in_panel(, please create a bug report at https://github.com/hacs/integration/issues Detected that custom integration 'hacs' accesses hass.helpers.event. This is deprecated and will stop working in Home Assistant 2024.11, it should be updated to import functions used from event directly at custom_components/hacs/base.py, line 630: self.hass.helpers.event.async_track_time_interval(, please create a bug report at https://github.com/hacs/integration/issues

danielbrunt57 commented 1 month ago

@f3bandit The recommended await hass.http.async_register_static_paths(... is already implemented in my current 4.10.3.1 release. alantse's 4.10.3 dev branch has the new code as well but they've not published a new release with it yet.

And no, it's not relevant to this issue as those message are only alerts and do not prevent the old code from working. When HA 2025.7 comes out, the hass.http.async_register_static_paths() will cease to exist and the code will fail completely. But that's still a year away.

Detected that custom integration 'hacs' calls hass.http.register_static_path which is deprecated because it does blocking I/O in the event loop, instead call await hass.http.async_register_static_paths([StaticPathConfig("/hacsfiles/frontend", "/config/custom_components/hacs/hacs_frontend", False)]); This function will be removed in 2025.7 at custom_components/hacs/frontend.py, line 54: hass.http.register_static_path(f"{URL_BASE}/frontend", locate_dir(), cache_headers=False), please create a bug report at https://github.com/hacs/integration/issues
Detected that custom integration 'hacs' calls hass.http.register_static_path which is deprecated because it does blocking I/O in the event loop, instead call await hass.http.async_register_static_paths([StaticPathConfig("/hacsfiles/iconset.js", "/config/custom_components/hacs/iconset.js", True)]); This function will be removed in 2025.7 at custom_components/hacs/frontend.py, line 57: hass.http.register_static_path(, please create a bug report at https://github.com/hacs/integration/issues

image

image

danielbrunt57 commented 1 month ago

404 error when setting up alexa intergration under services and devices.

You mean Devices & Services > Integrations! My released version config entry input looks like this:

image

Please post a screenshot of the one you are seeing and which fields you are completing.

f3bandit commented 1 month ago

image

danielbrunt57 commented 1 month ago

Which fields are you filling in?

f3bandit commented 1 month ago

email, password. built-in 2FA key, public url.

danielbrunt57 commented 1 month ago

Please post a screenshot of what you see after you SUBMIT

f3bandit commented 1 month ago

image

f3bandit commented 1 month ago

image

f3bandit commented 1 month ago

image

danielbrunt57 commented 1 month ago

Are you entering your public URL as https://my_unique_id.ui.nabu.casa/ (with training slash) or as https://my_unique_id.ui.nabu.casa (without trailing slash)?

f3bandit commented 1 month ago

with

f3bandit commented 1 month ago

I have even tried my local address and still get a 404

danielbrunt57 commented 1 month ago

Could you please retry your external nabu casa URL but without the trailing slash? I've been adding mine without the trailing slash and it succeeds. I just tried now with the slash and it still worked but I'm using my own public URL and not nabu casa. The URL I'm sent to is...

https://<my_external_url>/auth/alexamedia/proxy?config_flow_id=01J30DHW4KNFFW1AAQ4FCAVM6G&callback_url=https://<my_public_url>/auth/alexamedia/callback?flow_id%3D01J30DHW4KNFFW1AAQ4FCAVM6G
f3bandit commented 1 month ago

image image image image

danielbrunt57 commented 1 month ago

What is the URL of this page?

image

f3bandit commented 1 month ago

https:///auth/alexamedia/proxy?config_flow_id=01J317CKVVMKCBK6APXZB04E02&callback_url=https:///auth/alexamedia/callback?flow_id%3D01J317CKVVMKCBK6APXZB04E02

danielbrunt57 commented 1 month ago

and just to confirm, the in your reply is https://<redacted>.ui.nabu.casa?

f3bandit commented 1 month ago

and just to confirm, the in your reply is https://<redacted>.ui.nabu.casa?

correct sir

danielbrunt57 commented 1 month ago

I'm at a loss as to why nabu casa is rejecting the callback. Has this integration functioned previously with nabu casa?

f3bandit commented 1 month ago

yes when I used it back on the raspberry pie 4 that I had running home assistant. but we had a lightening strike that took out alot of stuff. so I upgraded it to a Home assistant yellow. idk if this matters or not, but idk if you are in the USA or not but i am. and you cannot access alexa.amazon.com anymore without scanning a QR code and using the alexa app. As I figured i would try the cookie method and since you cannot access alexa.amazon.com anymore thru a browser you cannot get the cookie anymore.

danielbrunt57 commented 1 month ago

I am in Canada and can use amazon.ca or amazon.com with my same account credentials (both require a 2FA TOTP code).
My echos are still in my amazon.com account and therefore use amazon.com. I also setup the Alexa skill (since I don't use Nabu Casa) in amazon.com, but that aspect is unrelated to Alexa Media Player.

danielbrunt57 commented 1 month ago

I've posted this topic in the community...

https://community.home-assistant.io/t/is-there-anyone-successfully-using-alexa-media-player-integration-in-conjunction-with-nabu-casa-for-their-public-url/750890

danielbrunt57 commented 1 month ago

There's been no useful replies on my topic yet so I went ahead and resubscribed to Nabu Casa Cloud, re-activated the HA cloud: component I had commented out, restarted HA and nabu casa is now active for me. I deleted my AMP integration, re-added it and my comnig setup completed successfully

image

So, there's no issues in the Alexa Media Player integration or Nabu Casa cloud. Something else is wrong/not working in your setup.

Can you log into your system remotely?

image

f3bandit commented 1 month ago

yes

image

f3bandit commented 1 month ago

I can even disconnect my phone from wifi and connect to it without issue image

f3bandit commented 1 month ago

idk what could be wrong tbh everything is pretty stock other than HACS being installed you are welcome to connect to my system and check stuff out if that helps!?!

f3bandit commented 1 month ago

Just did a fresh install of home assistant on the HA Yellow box. I still get a 404 error

f3bandit commented 1 month ago

seems to me the file is not being created, as its able to connect to HA but the filer or page itslooking for is in the wrong place or does not exsist image

f3bandit commented 1 month ago

just found this in the logs

Logger: homeassistant.components.http.ban Source: components/http/ban.py:135 integration: HTTP (documentation, issues) First occurred: 7:15:45 PM (1 occurrences) Last logged: 7:15:45 PM

Login attempt or request with invalid authentication from (redacted) ((redacted)). Requested URL: '/auth/alexamedia/proxy?config_flow_id=&callback_url=http://(redacted):8123/auth/alexamedia/callback?flow_id%'. (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36)

danielbrunt57 commented 1 month ago

What subnet is your public IP? (in Google, search for "what is my ip address"

Once http.ban is triggered, it may block the ip, at which point you have to edit config/ip_bans.yaml to remove the entry. that or just delete the file, and restart of course.

danielbrunt57 commented 1 month ago

I have no idea where 200.200.200.83 is coming from then...

f3bandit commented 1 month ago

I have no idea where 200.200.200.83 is coming from then...

it's my desktops IP on the network

danielbrunt57 commented 1 month ago

You'll need to sort through getting the HA Yellow box setup properly with remote access working via the nabu casa external URL...

f3bandit commented 1 month ago

fixed buit still get a 404 error

danielbrunt57 commented 1 month ago

Ok, so that post you made with "weird" and the image.png at 6:56 pm PDT and then deleted? well, I got email notification of the post and the png where you obfuscated most of your nabu casa URL's, except one. Anyways, I typed it character by character and I got your HA login screen (not that I can do anything with it without your user name & password!) but it proves to me the URL works externally. Now why are AMP & Nabu not happy with each other when they are on my system... I can feel another sleepless night coming on as these unsolved mysteries tend to keep me up all night!

danielbrunt57 commented 1 month ago

Okay, so I googled this: 404 not found ui.nabu.casa/ap/cvf/approval And that led me to this : https://github.com/alandtse/alexa_media_player/issues/1725 and I believe this is your issue. Also confirmed by looking again at your screeshots sbove where I see you are NOT getting to the Amazon OTP screen!

image

You appear to have app approval enabled on your amazon account, not OTP!

f3bandit commented 1 month ago

not sure what you mean there image this is what I have been using, is this wrong?

f3bandit commented 1 month ago

image

f3bandit commented 1 month ago

still get a 404

danielbrunt57 commented 1 month ago

Did you disable and re-enable 2SV?

danielbrunt57 commented 1 month ago

image

f3bandit commented 1 month ago

yes still 404

f3bandit commented 1 month ago

cleared my settings and apps and made sure app otp was the primary

danielbrunt57 commented 1 month ago

I don't know what to tell you. The problem is with your Amazon account, not Alexa Media Player...

f3bandit commented 1 month ago

Logger: homeassistant.components.http.ban Source: components/http/ban.py:135 integration: HTTP (documentation, issues) First occurred: July 18, 2024 at 9:58:01 PM (5 occurrences) Last logged: July 18, 2024 at 9:58:04 PM

Login attempt or request with invalid authentication from localhost (127.0.0.1). Requested URL: '/auth/token'. (Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36) Login attempt or request with invalid authentication from localhost (127.0.0.1). Requested URL: '/auth/token'. (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36)

danielbrunt57 commented 1 month ago

I think you're missing this? image

f3bandit commented 1 month ago

apparently there was a lock on my account as amazon believed someone was trying to hack my account I'm waiting for them to get it removed. I created a test amazon acount and everything worked perfect