First time Home Connect integration failing during OAuth

Hi all,

I’m trying my first time integration with Home Connect and/or Home Connect Alt from HACS, but whatever I do I always end up with the same issue at the end of the OAuth process, after I accept the account linking.
Current Version: 2023.4.4 (just upgrading to 2023.4.5 but I do not expect a different behaviour due to the release notes)

  • I have setup the application in the Home Connect Developer Portal (using same mail for Home Connect and Developer Portal)
  • Added https://my.home-assistant.io/redirect/oauth/ as redirect URL
  • Setup the my.home-assistant.io URL to point to my external https address, which is resolvable from the internet
  • Disabled Pi-hole blocking for my HA instance
  • Ensured that there is no credentials stored in the credentials store and have the required home_connect_alt part in my configuration.yaml file
  • added debug for certain services already
logger:
  default: info
  logs:
    homeassistant.helpers.config_entry_oauth2_flow: debug
    home_connect_async: debug
    home_connect_alt: debug
    custom_components.home_connect_alt: debug

but I still get the same error in the HC and HCA integration, after clicking on the “link account”

Logger: aiohttp.server
Source: helpers/config_entry_oauth2_flow.py:209
First occurred: April 17, 2023 at 7:34:11 PM (7 occurrences)
Last logged: 10:41:45 AM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/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 100, 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 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 171, 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.10/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')

I also tried different browsers, private browing etc

As I have no other integration with OAuth and this is the first time for me to setup Home Connect, I have no clue if anything might be missing or is just screwed with the 2023.4 version

So any help to see why I get a bad request response might be highly appreciated

Same issue from my side.

My version:
Home Assistant 2023.4.6
Supervisor 2023.04.0
Operating System 10.0 Frontend 20230411.1 - latest

After the approvement I got the following link page (correct instance URL → NOT my.home-assistant.io):
image
URL: https://my.home-assistant.io/redirect/oauth/?code=ey{LINKCODE}&grant_type=authorization_code

URL “Link Account”:
https:///auth/external/callback?code=ey{LINKCODE}

After clicking on “Link account” I got the following error after redirection to my HomeAssistant:
image

When I Copy/Paste the link in a new tab, I see the following error on my tab:
image

As test to exclude my WAF policy in CloudFlare, I have disabled all my WAF rules. No difference.

My error log:



Logger: aiohttp.server
Source: helpers/config_entry_oauth2_flow.py:209
First occurred: 4:58:40 PM (7 occurrences)
Last logged: 5:18:31 PM
Error handling request

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/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 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 171, 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.10/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')