core icon indicating copy to clipboard operation
core copied to clipboard

Home Connect Token Request Error

Open jscongdon opened this issue 1 year ago • 9 comments

The problem

The Home Connect integration is unable to load correctly. I have verified that Home Connect devices are connecting correctly to Home Connect servers by validating devices are present in the Home Connect app.

What version of Home Assistant Core has the issue?

core-2024.3.3

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

Home Connect

Link to integration documentation on our website

https://www.home-assistant.io/integrations/home_connect/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-03-30 14:14:25.997 ERROR (MainThread) [homeassistant.helpers.config_entry_oauth2_flow] Token request for home_connect_[CLIENT_ID_OBFUSCATED] failed (invalid_grant): invalid refresh_token
2024-03-30 14:14:25.998 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Home for home_connect
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/homeconnect/api.py", line 74, in request
return getattr(self._oauth, method)(url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/requests_oauthlib/oauth2_session.py", line 528, in request
url, headers, data = self._client.add_token(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 217, in add_token
raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/home_connect/__init__.py", line 229, in async_setup_entry
await update_all_devices(hass, entry)
File "/usr/src/homeassistant/homeassistant/components/home_connect/__init__.py", line 253, in update_all_devices
await hass.async_add_executor_job(hc_api.get_devices)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/home_connect/api.py", line 70, in get_devices
appl = self.get_appliances()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/homeconnect/api.py", line 136, in get_appliances
data = self.get(ENDPOINT_APPLIANCES)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/homeconnect/api.py", line 83, in get
res = self.request("get", endpoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/homeconnect/api.py", line 77, in request
self._oauth.token = self.refresh_tokens()
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/home_connect/api.py", line 64, in refresh_tokens
).result()
^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 519, in async_ensure_token_valid
new_token = await self.implementation.async_refresh_token(self.token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 94, in async_refresh_token
new_token = await self._async_refresh_token(token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 184, in _async_refresh_token
new_token = await self._token_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 217, in _token_request
resp.raise_for_status()
File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1060, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://api.home-connect.com/security/oauth/token')

Additional information

No response

jscongdon avatar Mar 30 '24 18:03 jscongdon

Hey there @davidmstraub, mind taking a look at this issue as it has been labeled with an integration (home_connect) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of home_connect can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign home_connect Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


home_connect documentation home_connect source (message by IssueLinks)

home-assistant[bot] avatar Mar 30 '24 18:03 home-assistant[bot]

I have the same problem after upgrading a working 2024.3.? to 2024.4.2.

nicetiger avatar Apr 10 '24 06:04 nicetiger

Same here, upgraded from 2024.2.0 to 2024.4.3. Token request for [redacted] failed (invalid_grant): invalid refresh_token.

Device still present in the Home Connect App.

More than willing to share further logs/infos if that would be helpful.

holgrrr avatar Apr 21 '24 10:04 holgrrr

Same here with 2024.5.5

Shadow23730 avatar May 29 '24 19:05 Shadow23730

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

I'm on the latest version of home connect and homeassistant and I've been hit by this. Please can someone advise?

ArthurMitchell42 avatar Sep 01 '24 19:09 ArthurMitchell42

My integration was working fine, and it stopped working recently. I checked the logs, and I've a 2.4GB file log with only this error for the home connect integration. I'm using Home Assistant 2024.7.4

@DavidMStraub do you have any idea of what could be causing it?

jaytonic avatar Sep 16 '24 17:09 jaytonic

I updated home assistant to the latest version (2024.9.2) and I don't get the error anymore. Not sure if that's a bug that has been fixed or that some cash has been cleared.

jaytonic avatar Sep 16 '24 18:09 jaytonic

@DavidMStraub do you have any idea of what could be causing it?

No. I haven't been involved in recent updates to the integration, but anyway the error 400 that is thrown means either the API is called incorrectly or it's responding incorrectly.

DavidMStraub avatar Sep 16 '24 19:09 DavidMStraub

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.