mitch-dc / volkswagen_we_connect_id

Apache License 2.0
204 stars 54 forks source link

Unexpected exception : OAuth 2 MUST utilize https #285

Open Alkaramazov opened 3 days ago

Alkaramazov commented 3 days ago

Hello,

The integration was unable to connect recently. I tried to re-download the integration. Then I uninstalled it, reinstalled it. Then I realized that I was affected by the classic problem: there were new conditions to accept on the VW website.

After accepting the conditions, I try again to add the integration, and when I enter the username and password, there's an unexpected error, about "OAuth 2 MUST utilize https". See logs below. I was trying to configure integration from the local URL (not HTTPS), so then I tried with the HTTPS URL provided by ui.nabu.casa. Same result

I've completely uninstalled and reinstalled integration with HACS (with reboots in between.) But still the same error. I've run out of ideas. How about you?

Version of the custom_component

0.2.3

Installation method (hacs / manual)

hacs

Home Assistant on Virtual Box

Core 2024.11.3 Supervisor 2024.11.4 Operating System 13.2 Frontend 20241106.2

Add your logs here.

Unexpected exception Traceback (most recent call last): File "/config/custom_components/volkswagen_we_connect_id/config_flow.py", line 65, in async_step_user info = await validate_input(self.hass, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/volkswagen_we_connect_id/config_flow.py", line 39, in validate_input await hass.async_add_executor_job(we_connect.login) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/weconnect/weconnect.py", line 184, in login self.__session.login() File "/usr/local/lib/python3.12/site-packages/weconnect/auth/we_connect_session.py", line 76, in login response = self.doWebAuth(authorizationUrl) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/weconnect/auth/we_connect_session.py", line 253, in doWebAuth afterLoginResponse = self.get(afterLoginUrl, allow_redirects=False, access_type=AccessType.NONE) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 602, in get return self.request("GET", url, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/weconnect/auth/we_connect_session.py", line 69, in request return super(WeConnectSession, self).request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/weconnect/auth/openid_session.py", line 188, in request raise InsecureTransportError() oauthlib.oauth2.rfc6749.errors.InsecureTransportError: (insecure_transport) OAuth 2 MUST utilize https.

torge70 commented 2 days ago

From another post: Log in to https://id.vwgroup.io/landing-page and accept new conditions.

Alkaramazov commented 2 days ago

yep, as explained, I was first affected by this. But then I have now another issue, regarding OAuth it seems.

Regards

zxdavb commented 2 days ago

I have the same problem, and I have logged onto https://id.vwgroup.io/landing-page; there was no prompt for me to accept new T&Cs.

To resolve my problem, I removed consent for everything, saved that, and restored consent again.

Error log (included again, as is formatted, so easier to read than OP):

2024-12-01 07:54:49.382 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Volkswagen We Connect ID for volkswagen_we_connect_id
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 635, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/volkswagen_we_connect_id/__init__.py", line 57, in async_setup_entry
    await hass.async_add_executor_job(_we_connect.login)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/weconnect/weconnect.py", line 184, in login
    self.__session.login()
  File "/usr/local/lib/python3.12/site-packages/weconnect/auth/we_connect_session.py", line 76, in login
    response = self.doWebAuth(authorizationUrl)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/weconnect/auth/we_connect_session.py", line 253, in doWebAuth
    afterLoginResponse = self.get(afterLoginUrl, allow_redirects=False, access_type=AccessType.NONE)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/weconnect/auth/we_connect_session.py", line 69, in request
    return super(WeConnectSession, self).request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/weconnect/auth/openid_session.py", line 188, in request
    raise InsecureTransportError()
oauthlib.oauth2.rfc6749.errors.InsecureTransportError: (insecure_transport) OAuth 2 MUST utilize https.
wherzig commented 2 days ago

From another post: Log in to https://id.vwgroup.io/landing-page and accept new conditions.

Thanks a lot. This resolved my "OAuth 2 MUST utilize https" issue! The integration is working again!

Alkaramazov commented 2 days ago

Thanks for the suggestions.

I tried removing all the consents, then accepting all the consents again. From the Android application, I reset the application, to be then forced to accept the consents again. I also deleted all access to the applications on https://id.vwgroup.io/landing-page , then reconnected the app and also accepted again from the myVolkswagen site (https://www.volkswagen.ch/fr/services/myvolkswagen.html).

But I still get the same result when I try to configure the integration, same error :-( It's driving me crazy...

Benny1907 commented 1 day ago

Ah my solution was to accept the New "Nutzer Vereinbarung" under user-administration in the Volkswagen App. Then it is working after reload of the application.

Alkaramazov commented 1 day ago

For the records, I also tried another VW integration : https://github.com/robinostlund/homeassistant-volkswagencarnet I also have an error when trying to login same VW account : "Login failed: Form POST request failed."

It really looks like I could fix this problem by "playing" with consents, but no solution find yet, already tried to reset everything I could...

Benny1907 commented 1 day ago

For the records, I also tried another VW integration : https://github.com/robinostlund/homeassistant-volkswagencarnet I also have an error when trying to login same VW account : "Login failed: Form POST request failed."

It really looks like I could fix this problem by "playing" with consents, but no solution find yet, already tried to reset everything I could...

Take a Look on my solution. Maybe it could help

Alkaramazov commented 1 day ago

Take a Look on my solution. Maybe it could help

Thank you @Benny1907

Sorry, I wasn't clear in my previous message: in fact I've also reset the Volkswagen App on my phone. Previously, I'd also deleted the permissions for connected apps, on id.vwgroup.io So I had to accept all the conditions again when I reconfigured the App. However, I don't understand where the ‘user agreement’ you're talking about is. Under user administration?

Alkaramazov commented 1 day ago

I also realise that I've deleted all the connected apps listed on https://id.vwgroup.io/. There were about 6. Now I only have 2. Maybe there was an app that represented connection from Home Assistant. And I don't see how Home Assistant integration could be explicitly authorised?

Benny1907 commented 1 day ago

Take a Look on my solution. Maybe it could help

Thank you @Benny1907

Sorry, I wasn't clear in my previous message: in fact I've also reset the Volkswagen App on my phone. Previously, I'd also deleted the permissions for connected apps, on id.vwgroup.io So I had to accept all the conditions again when I reconfigured the App. However, I don't understand where the ‘user agreement’ you're talking about is. Under user administration?

In your vw app- settings-administration-user administration. There I musst accept New user agreements with a few separate points for example allow ota and so on. And after reload of ha Integration it worked fine

Alkaramazov commented 13 hours ago

Thank you very much for your time @Benny1907 , I also tried this way but it leads to same user agreements. I noticed that this page https://www.volkswagen.ch/fr/services/myvolkswagen.html should also list "online mobile services" but currently there is only such an error message :

No access to online mobiles? Please update the page or try again later.

Btw, as you can see in this link, I'm in Switzerland. It looks like user agreement could be different between countries... I wonder if there is something like "local problem". Maybe I could open a support request by VW, but it will be complicated to explain them the case... :-P

Anyway, thanks for all theses suggestions, and happy it has helped some people here :-)

Best regards