CJNE / ha-porscheconnect

Porsche Connect custom component for Home Assistant
MIT License
28 stars 11 forks source link

Authentication flow not working anymore #206

Closed fastlorenzo closed 10 months ago

fastlorenzo commented 10 months ago

Version of the custom_component

0.0.16

Configuration

Module installed via HACS

Describe the bug

It is impossible to add a new account, the only error received is "connect". After investigation, it seems the authentication flow changed for Porsche Connect (see https://github.com/CJNE/pyporscheconnectapi/issues/34).

I've made a PR to the underlying library (https://github.com/CJNE/pyporscheconnectapi/issues/35) that fixes it, once merged this module should be updated to use the correct dependency and that should fix it. I've tested it in my on HA setup and it works with the proposed PR.

Debug log


N/A
tomw1964 commented 10 months ago

i have the same issue and am happy to test it - however I can't find the connection.py file. I am using the OS version of HA. I have only just installed so finding the correct file locations is confusing

hlyngerdi commented 10 months ago

Still not working for me after the update. I get a red ! Connect error when I try to login from setup.

barto64 commented 10 months ago

Still not working for me after the update. I get a red ! Connect error when I try to login from setup.

Until a new version of the ha-porscheconnect had been created you need manualy to update the manifest.json file to grab the latest version of the porscheconnectapi.

                       "requirements": ["pyporscheconnectapi==0.1.6"],

afterwards you need to remove the "pycache" directory of the "\custom_components\porscheconnect" and reboot HA.

It will make HA-Porscheconnect to use the amended version of the pyporscheconnectapi

It worked fine for me.

hlyngerdi commented 10 months ago

Thank you @barto64 the set up worked great and connected. But after a few hours it stopped working with the error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 399, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/porscheconnect/__init__.py", line 94, in async_setup_entry
    access_tokens = await controller.getAllTokens()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/client.py", line 32, in getAllTokens
    return await self._connection.getAllTokens()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 199, in getAllTokens
    token = await self._requestToken(application)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 206, in _requestToken
    await self._login()
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 183, in _login
    self.auth_state["code"] = params["code"][0]
                              ~~~~~~^^^^^^^^
KeyError: 'code'

But this seems to be on the pyporscheconnectapi side.