HomeAssistant-Mods / home-assistant-miele

Miele integration for Home assistant
138 stars 32 forks source link

Unable to authenticate: invalid_grant #126

Open scaarup opened 1 year ago

scaarup commented 1 year ago
Hi. I am able to authenticate on https://www.miele.com/developer/swagger-ui/swagger.html#/ with the creds I have defined in configuration.yaml, but the integration has stopped working. FYI, yesterday there was a firmware update for my dishwasher. ` 2022-08-29 12:10:09 2022-08-29 12:10:09.833 ERROR (MainThread) [homeassistant.setup] Error during setup of component miele Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 235, in _async_setup_component result = await task File "/config/custom_components/miele/init.py", line 152, in async_setup data_get_devices = await client.get_devices(lang) File "/config/custom_components/miele/miele_at_home.py", line 48, in get_devices home_devices = await self._get_devices_raw(lang) File "/config/custom_components/miele/miele_at_home.py", line 32, in _get_devices_raw if await self._session.refresh_token(self.hass): File "/config/custom_components/miele/miele_at_home.py", line 165, in refresh_token self._token = await hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) File "/config/custom_components/miele/miele_at_home.py", line 174, in sync_refresh_token return self._session.refresh_token( File "/usr/local/lib/python3.10/site-packages/requests_oauthlib/oauth2_session.py", line 452, in refresh_token self.token = self._client.parse_request_body_response(r.text, scope=self.scope) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 448, in parse_request_body_response self.token = parse_token_response(body, scope=scope) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response validate_token_parameters(params) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 448, in validate_token_parameters raise_from_error(params.get('error'), params) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 399, in raise_from_error raise cls(kwargs) oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) Show context
    2022-08-29 12:10:09 2022-08-29 12:10:09.770 INFO (MainThread) [custom_components.miele.miele_at_home] Request unauthorized - attempting token refresh
    2022-08-29 12:10:09 2022-08-29 12:10:09.011 INFO (MainThread) [homeassistant.setup] Setting up miele /config/custom_components/miele/miele_at_home.py:138: RuntimeWarning: coroutine 'MieleOAuth.refresh_token' was never awaited self.refresh_token(hass) RuntimeWarning: Enable tracemalloc to get the object allocation traceback

`

scaarup commented 1 year ago

I have tried to delete the integration completely, several times. I have generated new credentials also. I keep getting this error: 2022-08-31 08:52:50.799 ERROR (MainThread) [homeassistant.setup] Error during setup of component miele Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 235, in _async_setup_component result = await task File "/config/custom_components/miele/__init__.py", line 152, in async_setup data_get_devices = await client.get_devices(lang) File "/config/custom_components/miele/miele_at_home.py", line 48, in get_devices home_devices = await self._get_devices_raw(lang) File "/config/custom_components/miele/miele_at_home.py", line 32, in _get_devices_raw if await self._session.refresh_token(self.hass): File "/config/custom_components/miele/miele_at_home.py", line 165, in refresh_token self._token = await hass.async_add_executor_job( File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/miele/miele_at_home.py", line 174, in sync_refresh_token return self._session.refresh_token( File "/usr/local/lib/python3.10/site-packages/requests_oauthlib/oauth2_session.py", line 452, in refresh_token self.token = self._client.parse_request_body_response(r.text, scope=self.scope) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 448, in parse_request_body_response self.token = parse_token_response(body, scope=scope) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response validate_token_parameters(params) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 448, in validate_token_parameters raise_from_error(params.get('error'), params) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 399, in raise_from_error raise cls(**kwargs) oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant)

CaptainPerox commented 1 year ago

I am also getting the same error after not using home assistant for the last 2 months. Here you can find the log:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/requests_oauthlib/oauth2_session.py", line 483, in request url, headers, data = self._client.add_token( File "/usr/local/lib/python3.10/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/setup.py", line 235, in _async_setup_component result = await task File "/config/custom_components/miele/init.py", line 152, in async_setup data_get_devices = await client.get_devices(lang) File "/config/custom_components/miele/miele_at_home.py", line 48, in get_devices home_devices = await self._get_devices_raw(lang) File "/config/custom_components/miele/miele_at_home.py", line 29, in _get_devices_raw devices = await self.hass.async_add_executor_job(func) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 600, in get return self.request("GET", url, kwargs) File "/usr/local/lib/python3.10/site-packages/requests_oauthlib/oauth2_session.py", line 502, in request token = self.refresh_token( File "/usr/local/lib/python3.10/site-packages/requests_oauthlib/oauth2_session.py", line 452, in refresh_token self.token = self._client.parse_request_body_response(r.text, scope=self.scope) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 448, in parse_request_body_response self.token = parse_token_response(body, scope=scope) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response validate_token_parameters(params) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 448, in validate_token_parameters raise_from_error(params.get('error'), params) File "/usr/local/lib/python3.10/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 399, in raise_from_error raise cls(**kwargs) oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant)

scaarup commented 1 year ago

I got this resolved. What I eventually think did the trick, was this cache_path: /config/miele_token I was unable to locate the "default" token file, but I suspect there was some sort of invalid token file present on the system. (the cache_path must point to a file, not a directory. This is not mentioned in the documentation).

xm4rcell0x commented 1 year ago

I got this resolved. What I eventually think did the trick, was this cache_path: /config/miele_token I was unable to locate the "default" token file, but I suspect there was some sort of invalid token file present on the system. (the cache_path must point to a file, not a directory. This is not mentioned in the documentation).

thank you!

NexusHero commented 1 year ago

Where is the cache_path defined?

scaarup commented 1 year ago

Where is the cache_path defined?

In your config - optional.