Closed JvdMaat closed 8 months ago
Hello @JvdMaat,
that hard coded callback URL is part of the core functions of the oauth2 config flow. See homeassistant/helpers/config_entry_oauth2_flow.py
at line 39:
MY_AUTH_CALLBACK_PATH = "https://my.home-assistant.io/redirect/oauth"
I have not yet tried to find a way to customize the callback URL. But as the callback URL must be your HA instance, this should be part of HA itself. It should not be solved by any integration, that would like to use the oauth2 config flow. Because when you use a custom domain for your HA instance, all integrations must use this domain for the callback url.
Did you know, that when you open https://my.home-assistant.io/ in your web browser (ideally the same browser session where you manage your HA instance), you can modify/manage the real internal address where your HA is accessible?
There you could set https://hass.mydomain.com
. And the next time you try to register through an oauth2 config flow you should get successfully redirected to you HA instance.
I do this too, as I also use another internal domain name for my HA installation.
Yes, I have the my.home-assistant.io redirect setup, but since my URL is accessible over HTTPS both locally and from the internet under the same name, I was trying to use that as the callback. Since your README says:
(Remember to set a valid Callback Url. It might be the easiest to use https://my.home-assistant.io/redirect/oauth.)
I assumed it was optional. So rather than saying "It might be easiest to use", change that to "Make sure you use"
Okay. I understand and will change the README accordingly.
Thanks for clarification.
Thanks! Just makes things easier for the next person. (And not have to spend a lot of time troubleshooting to figure out why their callback URL does not work)
I had some issues adding a new API connection. In the integration code, the callback URL is hardcoded to https://my.home-assistant.io/redirect/oauth. So that gives me an Invalid API call (as I had my callback URL set to https://hass.mydomain.com/redirect/oauth) But by editing the URL coming from the integration, MyUplink worked and I was able to authorize access. But then the callback to HA gives me a 404: https://hass.mydomain.com/redirect/oauth?code=1C58*REDACTED*&scope=READSYSTEM%20WRITESYSTEM%20offline_access&state=eyJh*REDACTED* If try and I edit that URL and point to the my.home-assistant.io domain, it wants to know if I want to link account to HA. And if I click Link Account it gives me a 500 Server Error.
I redid the whole thing and used the suggested my.home-assistant.io link, and that worked. So can you update your docs and state that using that is mandatory? (Or allow for customizing the callback URL in the integration setup)