Closed jlatvala closed 4 months ago
Hi,
thanks. The Key-error is fixed in the latest beta.
The root cause is still unknown. I had this once this week and currently try to find out the root cause. In case you want help, please set the log level for the component to debug and share the log via email mbdev.i208@nulsch.de after it happens again.
Just had the reauthentification issue after installing latest stable, then installed latest beta. Now works again.
Unfortunatly Debug log downloaded does not contain the error messages before restart, but at least I can confirm beta is working for me.
Thx for all your work.
KR
Kneip
I had the same KeyError: 'entry_id'
and thus upgraded to v0.11.2-beta.1 but now I have a different problem:
I still get Authentication failed. Please reauthenticate.
but it is persistent now (i.e. the error appears each time after I re-authenticate) and the exception is this:
ERROR (MainThread) [custom_components.mbapi2020.oauth] Error requesting: https://id.mercedes-benz.com/as/token.oauth2
- 0 - {"error_description":"unknown, invalid, or expired refresh token","error":"invalid_grant"}
Is this a wholly separate issue? Any ideas how to fix it?
I had the same
KeyError: 'entry_id'
and thus upgraded to v0.11.2-beta.1 but now I have a different problem: I still getAuthentication failed. Please reauthenticate.
but it is persistent now (i.e. the error appears each time after I re-authenticate) and the exception is this:ERROR (MainThread) [custom_components.mbapi2020.oauth] Error requesting: https://id.mercedes-benz.com/as/token.oauth2 - 0 - {"error_description":"unknown, invalid, or expired refresh token","error":"invalid_grant"}
Is this a wholly separate issue? Any ideas how to fix it?
Same here. I can't reauthenticate now anymore with the same error. I also reinstalled the last stable but same issue.
I have published a new beta version v0.11.2-beta2
This adds some special handling to hopefully address the issue.
I have published a new beta version v0.11.2-beta2
This adds some special handling to hopefully address the issue.
Unfortunatley not.
2024-03-04 13:26:03.728 DEBUG (MainThread) [custom_components.mbapi2020] Start async_setup_entry.
2024-03-04 13:26:03.728 DEBUG (MainThread) [custom_components.mbapi2020.client] WSL not detected - running in rlock mode
2024-03-04 13:26:03.728 DEBUG (MainThread) [custom_components.mbapi2020.oauth] Start async_get_cached_token()
2024-03-04 13:26:03.729 DEBUG (MainThread) [custom_components.mbapi2020.oauth] custom_components.mbapi2020.oauth token expired -> start refresh
2024-03-04 13:26:03.729 INFO (MainThread) [custom_components.mbapi2020.oauth] Start async_refresh_access_token() with refresh_token
2024-03-04 13:26:03.729 INFO (MainThread) [custom_components.mbapi2020.oauth] Auth token refresh preflight request 1
2024-03-04 13:26:03.731 DEBUG (MainThread) [custom_components.mbapi2020] Can not connect to MB OAuth API https://id.mercedes-benz.com. Will try again.
Sorry, my mistake - the dev proxy was still active. I have published a new beta release v0.11.2-beta.3
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht
Logger: custom_components.mbapi2020.oauth Source: custom_components/mbapi2020/oauth.py:317 Integration: MercedesME 2020 (documentation, issues) First occurred: 14:15:47 (2 occurrences) Last logged: 14:19:57
Error requesting: https://id.mercedes-benz.com/as/token.oauth2 - 0 - {"error_description":"unknown, invalid, or expired refresh token","error":"invalid_grant"}
When i then try again, i don't receive a new PIN anymore via mail and the integration will not stop to ask for a PIN which i never receive.
Are you sure that you installed the latest beta version 0.11.2-beta.3? Please enable the debug log and restart HA. Then try again to request a pin.
Yes
Could you open a new issue and share the debug log, system information, please - we have to analyze why you don't get a pin.
Sure i can do, but i don't think it has anything to do with the mail itself. Still getting this:
2024-03-04 15:48:58.577 DEBUG (MainThread) [custom_components.mbapi2020] Start async_setup_entry.
2024-03-04 15:48:58.577 DEBUG (MainThread) [custom_components.mbapi2020.client] WSL not detected - running in rlock mode
2024-03-04 15:48:58.577 DEBUG (MainThread) [custom_components.mbapi2020.oauth] Start async_get_cached_token()
2024-03-04 15:48:58.578 DEBUG (MainThread) [custom_components.mbapi2020.oauth] custom_components.mbapi2020.oauth token expired -> start refresh
2024-03-04 15:48:58.578 INFO (MainThread) [custom_components.mbapi2020.oauth] Start async_refresh_access_token() with refresh_token
2024-03-04 15:48:58.578 INFO (MainThread) [custom_components.mbapi2020.oauth] Auth token refresh preflight request 1
Did you rerun the reauth procedure? What is the log entry after preflight?
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht
Logger: custom_components.mbapi2020.oauth Source: custom_components/mbapi2020/oauth.py:317 Integration: MercedesME 2020 (documentation, issues) First occurred: 15:49:07 (2 occurrences) Last logged: 16:24:10
Error requesting: https://id.mercedes-benz.com/as/token.oauth2 - 0 - {"error_description":"unknown, invalid, or expired refresh token","error":"invalid_grant"}
Could please try to be a little bit more descriptive otherwise I cant help you? This error message is not an reauth-error. If you don't want to do this, then you can only delete the integration from the HA integration page and re-add it to get a clean state.
But this was the answer of your request. I don't had any other error in the log right after the preflight.
Also i think there is no other request for a new PIN if no Pin or a wrong or a expired pin has been entered. This need to be handled by the integration i guess. But in my case without a PIN or an expired there is no way to request a new one.
Thank you @ReneNulschDE for taking the time to help us. I'll try to add what I can.
2024-03-04 18:43:33.047 INFO (MainThread) [custom_components.mbapi2020.oauth] Start request PIN <redacted@mail.com>
2024-03-04 18:43:33.047 INFO (MainThread) [custom_components.mbapi2020.oauth] PIN preflight request 1
2024-03-04 18:43:33.252 INFO (MainThread) [custom_components.mbapi2020.oauth] PIN request
2024-03-04 18:43:41.449 DEBUG (MainThread) [custom_components.mbapi2020] Token received
2024-03-04 18:43:41.452 DEBUG (MainThread) [custom_components.mbapi2020] Start async_setup_entry.
2024-03-04 18:43:41.453 DEBUG (MainThread) [custom_components.mbapi2020.client] WSL not detected - running in rlock mode
2024-03-04 18:43:41.453 DEBUG (MainThread) [custom_components.mbapi2020.oauth] Start async_get_cached_token()
2024-03-04 18:43:41.455 DEBUG (MainThread) [custom_components.mbapi2020.oauth] custom_components.mbapi2020.oauth token expired -> start refresh
2024-03-04 18:43:41.456 INFO (MainThread) [custom_components.mbapi2020.oauth] Start async_refresh_access_token() with refresh_token
2024-03-04 18:43:41.456 INFO (MainThread) [custom_components.mbapi2020.oauth] Auth token refresh preflight request 1
2024-03-04 18:43:41.721 ERROR (MainThread) [custom_components.mbapi2020.oauth] Error requesting: https://id.mercedes-benz.com/as/token.oauth2 - 0 - {"error_description":"unknown, invalid, or expired refresh token","error":"invalid_grant"}
2024-03-04 18:43:41.722 ERROR (MainThread) [custom_components.mbapi2020] Authentication failed. Please reauthenticate.
So far I am hesitant to just remove and install the integration again because I am worried that some entities might end up with different names or similar which would break my code. Let us know if you feel like you can't easily fix this, then I'll just take the bullet. ;)
@fvbrandt : Thanks for the details. Do you have the option to click on the "configure" link on the integration page?
@fvbrandt : Thanks for the details. Do you have the option to click on the "configure" link on the integration page?
💯 That was the right hint! Under the three-dot-menu there was the "configure" option and there I only chose "Delete authentication token file now. require a restart of Home Assistant after save." and pressed submit. Then restart and one final re-authentication and this time it worked. So I guess it was a missing cache invalidation in some place?
Thanks - let me try to find out why HA does not store the new token. We see in your log that after 3ms the reload starts, I assume that the token is not saved.
@dersch81 : Can you try the same?
Thanks - let me try to find out why HA does not store the new token. We see in your log that after 3ms the reload starts, I assume that the token is not saved.
@dersch81 : Can you try the same?
Yes, that fixed it! Many thanks! I did never notice that option but now i will never forget :)
Beta version & re-auth sorted this for me. Thanks as always @ReneNulschDE!
The problem
Every now and then (about once per week) authentication fails and I have to delete and add integration again.
Logs: 2024-03-01 13:12:44.028 ERROR (MainThread) [custom_components.mbapi2020.oauth] Error requesting: https://id.mercedes-benz.com/as/token.oauth2 - 0 - {"error_description":"unknown, invalid, or expired refresh token","error":"invalid_grant"} 2024-03-01 13:12:44.029 ERROR (MainThread) [custom_components.mbapi2020] Authentication failed. Please reauthenticate. 2024-03-01 13:12:44.114 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 948, in async_init flow, result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 976, in _async_init result = await self._async_handle_step(flow, flow.init_step, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 501, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/mbapi2020/config_flow.py", line 128, in async_step_reauth self._reauth_entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])