ekutner / home-connect-hass

Alternative (and improved) Home Connect integration for Home Assistant
MIT License
569 stars 55 forks source link

README: update redirect URL for new oauth apps #390

Closed vrutkovs closed 3 months ago

vrutkovs commented 3 months ago

Apparently since some time in 2023 setting up new apps requires a different oauth URL. I've just tried setting up a new app on a brand new account and setting https://my.home-assistant.io/redirect/oauth is no longer sufficient. Same for http://192.168.0.230:8123/auth/external/callback.

However setting https://my.home-assistant.io/redirect/config_flow_start?domain=home_connect_alt did the trick. See https://github.com/ekutner/home-connect-hass/issues/62#issuecomment-1656720612

ekutner commented 3 months ago

I don't believe this is generally correct. The documented URL is the one coded in the Home Assistant code and it works for me and most people or there would have been a ton of cases opened about it. To be honest, It's not clear to me where the other URL is coming from. Are you using Nabu Casa and can you verify that the "my" integration is enabled?

vrutkovs commented 3 months ago

I'm not sure why or how this works, this is just the experimental result I know of

Are you using Nabu Casa and can you verify that the "my" integration is enabled?

No, completely seflhosted HA

ekutner commented 3 months ago

It's definitely not the standard behavior and, as I mentioned, it's not clear to me when it happens. Would you mind opening an issue for this so we can try to figure out when it happens and give better guidance to other users. In the ticket please include the following:

  1. A screenshot of https://my.home-assistant.io/
  2. Add this block to your configuration.yaml:
    logger:
    default: info
    logs:
    homeassistant.helpers.config_entry_oauth2_flow: debug
  3. Disconnect from Home Connect, connect again and copy the "my.home-assistant.io" URL it lands on. Include the URL in the issue.
  4. Attach the home assistant log file
vrutkovs commented 3 months ago

image

oh well, now I removed the integration, tried to reproduce it setting ../config_flow_start - and it failed, redirecting me to https://api.home-connect.com/security/oauth/authorize?response_type=code&client_id=4138618A2E661494EDA94685307C7DA0DBC8389B2BC9214C8C40721A76D53958&redirect_uri=https://my.home-assistant.io/redirect/oauth&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmbG93X2lkIjoiYWVhMWU4M2ZjYmI3ODNhMjM4NmZlODdjMzcxMzRhMDkiLCJyZWRpcmVjdF91cmkiOiJodHRwczovL215LmhvbWUtYXNzaXN0YW50LmlvL3JlZGlyZWN0L29hdXRoIn0.vgZlrQOq91D-SoRLGYPEKgnLEybnGJzeVnQg3Zs5oe0&scope=IdentifyAppliance+Monitor+Control+Settings. This threw unauthorized client. If I change it to redirect_uri=https://my.home-assistant.io/redirect/config_flow_start I get correct login page. However, later on it opens config dialog again and the process becomes an endless loop. Failed attempt logs:

2024-06-15 16:13:57.941 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Resumed OAuth configuration flow
2024-06-15 16:13:58.038 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Creating config entry from external data
2024-06-15 16:13:58.039 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Sending token request to https://api.home-connect.com/security/oauth/token
2024-06-15 16:13:58.221 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Token request for home_connect_alt_a735980e74cd7fe671d0586fa63eadd0debf6dccc94b627636047c349747f593 failed (invalid_grant): incorrect redirect_uri parameter
2024-06-15 16:13:58.222 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Error resolving OAuth token: 400, message='Bad Request', url=URL('https://api.home-connect.com/security/oauth/token')

After tweaking redirect URLs multiple times I finally managed to setup the app using https://my.home-assistant.io/redirect/oauth - exactly like the original README.md claimed. I'm very confused and have no idea why this didn;t work the first time for me (and few more people in #62)