The problem
I am trying to setup the Home Connect integration, I have obtained the credentials and setup the application with my own redirect URI: <HOME_ASSISTANT_URL>/auth/external/callback
I have checked and the url works from outside, I have also checked the configuration.yaml and I have the following:
default_config: null
homeassistant:
external_url: <HOME_ASSISTANT_URL>
internal_url: <HOME_ASSISTANT_URL>
When I click Add integration and enter my credentials I am redirected to another page with the redirect_uri set like this: redirect_uri=https://my.home-assistant.io/redirect/oauth
this obviously gives the error:
{
"error": "unauthorized_client",
"error_description": "client or redirection URI not authorized",
"state": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmbG93X2lkIjoiNTI4YTRlNmY5NDc0YzJmM2MxMWE4ZTBlOWVhYjRmZGQiLCJyZWRpcmVjdF91cmkiOiJodHRwczovL215LmhvbWUtYXNzaXN0YW50LmlvL3JlZGlyZWN0L29hdXRoIn0.wHRexMQ3HuCTQE4IIrTA2EAoNN9jHCc7KbNYp1MLWcs"
}
I have tried to manually change the URI in the login bar, this makes the process work ok, returns to home-assistant, but gives a bad request error like so (with oauth2 debug enabled):
2023-06-25 16:11:06.358 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Resumed OAuth configuration flow
2023-06-25 16:11:06.389 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Creating config entry from external data2023-06-25 16:11:06.390 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Sending token request to https://api.home-connect.com/security/oauth/token
2023-06-25 16:11:06.562 DEBUG (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Token request failed with status=400, body={
"error": "invalid_grant",
"error_description": "incorrect redirect_uri parameter"
}
2023-06-25 16:11:06.563 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 172, in get
return await super().get(request, flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 96, in get
result = await self._flow_mgr.async_configure(flow_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
result = await self._async_handle_step(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 315, in async_step_creation
token = await self.flow_impl.async_resolve_external_data(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 172, in async_resolve_external_data
return await self._token_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 209, in _token_request
resp.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://api.home-connect.com/security/oauth/token')
"incorrect redirect_uri parameter" sounds like home-assistant tries to use the https://my.home-assistant.io/redirect/oauth redirect_uri. I have read around a few issues but can't seem to find anything that works
What have I missed ? How can I make it use the proper uri ?
What version of Home Assistant Core has the issue?
core-2023.6.0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
No response
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
The problem
I am trying to setup the Home Connect integration, I have obtained the credentials and setup the application with my own redirect URI: <HOME_ASSISTANT_URL>/auth/external/callback
I have checked and the url works from outside, I have also checked the configuration.yaml and I have the following:
When I click Add integration and enter my credentials I am redirected to another page with the redirect_uri set like this: redirect_uri=https://my.home-assistant.io/redirect/oauth
this obviously gives the error:
I have tried to manually change the URI in the login bar, this makes the process work ok, returns to home-assistant, but gives a bad request error like so (with oauth2 debug enabled):
"incorrect redirect_uri parameter" sounds like home-assistant tries to use the https://my.home-assistant.io/redirect/oauth redirect_uri. I have read around a few issues but can't seem to find anything that works
What have I missed ? How can I make it use the proper uri ?
What version of Home Assistant Core has the issue?
core-2023.6.0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
No response
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response