CoMPaTech / stromer

Stromer custom_component for Home Assistant
MIT License
13 stars 4 forks source link

[BUG]: Investigate API instability (v3 v v4) #29

Closed CoMPaTech closed 6 months ago

CoMPaTech commented 1 year ago

Renamed

To api instability due to discussion below - main comment is not updated accordingly (yet)

Describe the bug.

Basic recovery (as per https://speedpedelecreview.com/forum/viewtopic.php?p=135684#p135684) is to delete and re-add the integration ensuring you have your v4 client_id ready. So it will be MITM sniffing again unfortunately if you still relied on v3 client_id/client_secret combination.

DO NOT DO THIS / NOT RESPONSIBLE FOR BREAKING YOUR HA-instance But since people might want to do it: Manually tinkering with .storage/core.config_entries having the v4 client_id readily available is an option, but should be handled with care (i.e. not responsible for typo's breaking your HA from even starting up). Ensure that you type proper JSON (i.e. most likely the client_secret will not have a , ending the line, when updating your client_id or whatever the last line will be when removing secret, should not have ,. Forgetting or typo-ing in .storage will ensure HA not starting up.

What version of Home Assistant Core has the issue?

n/a

What was the last working version of Home Assistant Core?

n/a

What type of installation are you running?

Home Assistant OS

How did you install the stromer integration

HACS

Logging

Most likely v3 private API disabled on stromer side

Diagnostics information

No response

Additional information

No response

f-idelio commented 1 year ago

The issue seems not related to the V3 being outdated and to be replaced by V4. I have opened an issue with another Stromer API call GitHub that uses V4 some weeks ago https://github.com/elnkosc/stromer_api/. Same problem there.

The issue is in the second authorization step, when requesting the access token from the Stromer servers. First step getting the code response (with username and password as input) works fine. Then when trying to get the access token (with code from step 1 and client_id) it fails.

CoMPaTech commented 1 year ago

@f-idelio Ah ok and weird. I falsely assumed as just changing to my v4 seemed to solve the issue.

f-idelio commented 1 year ago

I'm actually using the python script homeassistant-stromersensor from @johannusNL using appdeamon add-on in HA. I had changed this script to v4 myself a year or so ago. There it also fails in getting the access token. I have not much knowledge on these API and how to use them. Just some basic programming skills. So I could only debug to the point where the failure occurs. But not the reason why it fails.

CoMPaTech commented 1 year ago

I had debugging how/why on my radar for (sometime/hopefully) this week. As for the code in this repo (specifically the stromer.py from the directory) it fails on L128 as it does not have anything to split on. Not sure why it 'just works' when accessing on v4

CoMPaTech commented 6 months ago

Closing (for now)