Closed OrangeReaper closed 1 year ago
Have we any update on this yet or will it be in the new HA update? I have tried it today with older Hive versions and still won’t register as per the original post
I have the same issue, any update?
Appears to caused by broken code here in hive_auth.py line507 auth_params = ({"REFRESH_TOKEN": token},) , creates a tuple, not a dict.
Are you logging in with 2fa enabled?
also hive is having issues with their app currently where 2 fa is enabled and doesn’t work. People are having to go back to old versions of the app to get 2fa working
Are you logging in with 2fa enabled?
also hive is having issues with their app currently where 2 fa is enabled and doesn’t work. People are having to go back to old versions of the app to get 2fa working
I tried both (viz: Changing 2FA settings on Hive App makes no difference).
Do you know what version is reliable?
Here is a link to some posts and thread of people who have managed to get around it https://github.com/home-assistant/core/issues/81417#issuecomment-1328795022
Here is a link to some posts and thread of people who have managed to get around it home-assistant/core#81417 (comment)
This, indeed, fixed the problem. Thank you kindly!
I'm new here but just looking at this is this really a fix? Isn't the problem that the code works only if device tracking (via 2FA) is enabled. The Exception looks like this one: https://stackoverflow.com/questions/46879876/aws-cognito-invalid-refresh-token So isn't solution to be be able to turn off device tracking somehow so that even without 2FA the system will authenticate. Looking at code .. https://github.com/Pyhass/Pyhiveapi/blob/480989bfb601784c3a28572d95c08c9237feba88/pyhiveapi/apyhiveapi/api/hive_auth.py, line 507 appears to be the broken bit >> 507> auth_params = ({"REFRESH_TOKEN": token},) as, acc to that cognito info, if you don't pass a device key then the authentication will generate the described exception.
All I can say is, changing the app on my phone fixed the problem for me (and others).
If you think there is a bug in the component then I suggest you raise a new issue for the devs to look at.
I'm new here but just looking at this is this really a fix? Isn't the problem that the code works only if device tracking (via 2FA) is enabled. The Exception looks like this one: https://stackoverflow.com/questions/46879876/aws-cognito-invalid-refresh-token So isn't solution to be be able to turn off device tracking somehow so that even without 2FA the system will authenticate. Looking at code .. https://github.com/Pyhass/Pyhiveapi/blob/480989bfb601784c3a28572d95c08c9237feba88/pyhiveapi/apyhiveapi/api/hive_auth.py, line 507 appears to be the broken bit >> 507> auth_params = ({"REFRESH_TOKEN": token},) as, acc to that cognito info, if you don't pass a device key then the authentication will generate the described exception.
@StephenGrey just for clarity this isn’t a bug. Hive have enforced 2FA when using the Hive app. hive are the ones who control the aws cognito setup. If you test Hive website I imagine you will find that it logs the user out after 1 hour and doesn’t refresh the token. This library mirrors the app and not the website.
The home assistant documentation does advise that 2FA must be enabled for this integration to work. - https://www.home-assistant.io/integrations/hive/
This library is far from perfect and could be made better by putting clear messaging in the route where 2FA isn’t enabled. But I have other priorities outside of the home assistant world which I need to focus on. This is open source code and I would welcome PR’s from anyone who wants to make it better.
I'm new here but just looking at this is this really a fix? Isn't the problem that the code works only if device tracking (via 2FA) is enabled. The Exception looks like this one: https://stackoverflow.com/questions/46879876/aws-cognito-invalid-refresh-token So isn't solution to be be able to turn off device tracking somehow so that even without 2FA the system will authenticate. Looking at code .. https://github.com/Pyhass/Pyhiveapi/blob/480989bfb601784c3a28572d95c08c9237feba88/pyhiveapi/apyhiveapi/api/hive_auth.py, line 507 appears to be the broken bit >> 507> auth_params = ({"REFRESH_TOKEN": token},) as, acc to that cognito info, if you don't pass a device key then the authentication will generate the described exception.
@StephenGrey just for clarity this isn’t a bug. Hive have enforced 2FA when using the Hive app. hive are the ones who control the aws cognito setup. If you test Hive website I imagine you will find that it logs the user out after 1 hour and doesn’t refresh the token. This library mirrors the app and not the website.
The home assistant documentation does advise that 2FA must be enabled for this integration to work. - https://www.home-assistant.io/integrations/hive/
This library is far from perfect and could be made better by putting clear messaging in the route where 2FA isn’t enabled. But I have other priorities outside of the home assistant world which I need to focus on. This is open source code and I would welcome PR’s from anyone who wants to make it better.
Understood and happy to have a go :-) ... just trying to work out how to fork an integration and test a change. New on Hass.
Please let me know when you sort it, I'm no good at coding but very interested in getting hive linked to HA. It fails to connect to my account, I've tried 2FA on and off :(
Sent from Outlook for Androidhttps://aka.ms/AAb9ysg
From: StephenGrey @.> Sent: Sunday, March 12, 2023 5:12:20 PM To: Pyhass/Hive-Custom-Component @.> Cc: Ryderbrew @.>; Comment @.> Subject: Re: [Pyhass/Hive-Custom-Component] [BUG] Authentication fails after update to HA (Issue #137)
I'm new here but just looking at this is this really a fix? Isn't the problem that the code works only if device tracking (via 2FA) is enabled. The Exception looks like this one: https://stackoverflow.com/questions/46879876/aws-cognito-invalid-refresh-token So isn't solution to be be able to turn off device tracking somehow so that even without 2FA the system will authenticate. Looking at code .. https://github.com/Pyhass/Pyhiveapi/blob/480989bfb601784c3a28572d95c08c9237feba88/pyhiveapi/apyhiveapi/api/hive_auth.py, line 507 appears to be the broken bit >> 507> auth_params = ({"REFRESH_TOKEN": token},) as, acc to that cognito info, if you don't pass a device key then the authentication will generate the described exception.
@StephenGreyhttps://github.com/StephenGrey just for clarity this isn’t a bug. Hive have enforced 2FA when using the Hive app. hive are the ones who control the aws cognito setup. If you test Hive website I imagine you will find that it logs the user out after 1 hour and doesn’t refresh the token. This library mirrors the app and not the website.
The home assistant documentation does advise that 2FA must be enabled for this integration to work. - https://www.home-assistant.io/integrations/hive/
This library is far from perfect and could be made better by putting clear messaging in the route where 2FA isn’t enabled. But I have other priorities outside of the home assistant world which I need to focus on. This is open source code and I would welcome PR’s from anyone who wants to make it better.
Understood and happy to have a go :-) ... just trying to work out how to fork an integration and test a change. New on Hass.
— Reply to this email directly, view it on GitHubhttps://github.com/Pyhass/Hive-Custom-Component/issues/137#issuecomment-1465250785, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARFVJWBPKLWM3EKSXOMUA2LW3X7XJANCNFSM6AAAAAATYIMXQE. You are receiving this because you commented.Message ID: @.***>
@Ryderbrew i think what we are suggesting here won’t fix the Hive issue with 2FA as advised before this isn’t a bug just a problem hive is having with 2FA where it gets itself confused. It seems to have occurred over a series of updates
I'm new here but just looking at this is this really a fix? Isn't the problem that the code works only if device tracking (via 2FA) is enabled. The Exception looks like this one: https://stackoverflow.com/questions/46879876/aws-cognito-invalid-refresh-token So isn't solution to be be able to turn off device tracking somehow so that even without 2FA the system will authenticate. Looking at code .. https://github.com/Pyhass/Pyhiveapi/blob/480989bfb601784c3a28572d95c08c9237feba88/pyhiveapi/apyhiveapi/api/hive_auth.py, line 507 appears to be the broken bit >> 507> auth_params = ({"REFRESH_TOKEN": token},) as, acc to that cognito info, if you don't pass a device key then the authentication will generate the described exception.
@StephenGrey just for clarity this isn’t a bug. Hive have enforced 2FA when using the Hive app. hive are the ones who control the aws cognito setup. If you test Hive website I imagine you will find that it logs the user out after 1 hour and doesn’t refresh the token. This library mirrors the app and not the website.
The home assistant documentation does advise that 2FA must be enabled for this integration to work. - https://www.home-assistant.io/integrations/hive/
This library is far from perfect and could be made better by putting clear messaging in the route where 2FA isn’t enabled. But I have other priorities outside of the home assistant world which I need to focus on. This is open source code and I would welcome PR’s from anyone who wants to make it better.
Sent you a PR which has a go at fixing (and creates a demo environment to test it ) - works for me now outside the Hass - not familiar with how to test within Hass environment.
@StephenGrey Thanks I’ll take a look
Describe the bug I updated HA to latest version today and hive integration now fails to initialise
To Reproduce Reload the integration; the following log is generated
This error originated from a custom integration.
Logger: homeassistant.config_entries Source: custom_components/hive/init.py:89 Integration: Hive First occurred: 16:35:41 (2 occurrences) Last logged: 16:45:36
Error setting up entry for hive
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 382, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/hive/init.py", line 89, in async_setup_entry
devices = await hive.session.startSession(hive_config)
File "/usr/local/lib/python3.10/site-packages/apyhiveapi/session.py", line 503, in startSession
await self.getDevices("No_ID")
File "/usr/local/lib/python3.10/site-packages/apyhiveapi/session.py", line 426, in getDevices
await self.hiveRefreshTokens()
File "/usr/local/lib/python3.10/site-packages/apyhiveapi/session.py", line 304, in hiveRefreshTokens
result = await self.auth.refresh_token(
File "/usr/local/lib/python3.10/site-packages/apyhiveapi/api/hive_auth_async.py", line 548, in refresh_token
result = await self.loop.run_in_executor(
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/botocore/client.py", line 391, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python3.10/site-packages/botocore/client.py", line 691, in _make_api_call
request_dict = self._convert_to_request_dict(
File "/usr/local/lib/python3.10/site-packages/botocore/client.py", line 739, in _convert_to_request_dict
request_dict = self._serializer.serialize_to_request(
File "/usr/local/lib/python3.10/site-packages/botocore/validate.py", line 360, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter AuthParameters, value: ({'REFRESH_TOKEN': 'eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiUlNBLU9BRVAifQ.Y_VC8Hg47BEdto_dYjkQzRBzkO9MkpNo6uo5jAFKzd84baD86W2E0qlLmChZbLAABUIs2DikE9WSrVEZPXKK_ZEEhwUhkDMePGHeuxER1cPT9YQuN17py9-qEUj7NXPYzUh6VBrHmaIG_lCVIb8Q3ZyxmRpG9L8ZWis-v0yL9jvHsFY0GSjl74_WJaYDhtSygDGSmhfm5nbvpHUezapMuTiuiwoVcpwgXg-Zki2f3ebxwkk-ybVgPDRWCVWiyjo9hAM1vqQQi9KGw23kTE6wdvl6rVQzLjgoBR3xAde51GB7rE63EZq1WgeDS1CUDUhaOM4GdKvs-bI_E741S9Pu6A.Dhzuwsq9fZ5vGuSg.7EYiFcw1dt-9f3Ql9_YZcgcOGn_WFWEKEwu84K4FF0OKlqdFkrqvoCE6Vdak5yMI_6gCuJFbwuKN0efBoJDpuJbsJXlCexojXco5kggaW_FJv0BImXQ7iJvM31sQDUDpX6LaurPVDHGqdP84jZTsUCk5oR6GyIM_LEV1qYutwwNaMa8mM7ssFuvM-InJbrRn2fEPEzSyPaI0l1aCL7X7O83cJlwBAyymb_Yo4PrSi3ji2ZVdXROUTcrWI4pOtPSQWA7JFJe_ryxlhdBG2E-YieG8muM1BGqlQykZlKg4qPm8Le9SNB2_ZqX9xaNhZfBQID-GjOR4ldEdlPEREOpV_lmt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tKg-0tnE396GYeAQ.kzetloy2578IxEqgy3YVcw'},), type: <class 'tuple'>, valid types: <class 'dict'>
Expected behaviour This appears to be an authentication failure... I expected it to authenticate properly
Additional context