home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.09k stars 30.18k forks source link

Home Connect Token Request Error #114494

Open jscongdon opened 6 months ago

jscongdon commented 6 months ago

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

home-assistant[bot] commented 6 months ago

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)

nicetiger commented 5 months ago

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

holgrrr commented 5 months ago

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.

Shadow23730 commented 4 months ago

Same here with 2024.5.5

issue-triage-workflows[bot] commented 1 month ago

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.

ArthurMitchell42 commented 1 month ago

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

jaytonic commented 2 weeks ago

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 commented 2 weeks ago

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.

DavidMStraub commented 2 weeks ago

@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.