Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected exception : OAuth 2 MUST utilize https #285

Closed
Alkaramazov opened this issue Nov 30, 2024 · 30 comments
Closed

Unexpected exception : OAuth 2 MUST utilize https #285

Alkaramazov opened this issue Nov 30, 2024 · 30 comments

Comments

@Alkaramazov
Copy link

Alkaramazov commented Nov 30, 2024

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
Copy link

torge70 commented Dec 1, 2024

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

@Alkaramazov
Copy link
Author

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

Regards

@zxdavb
Copy link

zxdavb commented Dec 1, 2024

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
Copy link

wherzig commented Dec 1, 2024

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
Copy link
Author

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
Copy link

Benny1907 commented Dec 2, 2024

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link

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
Copy link
Author

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

@andynash
Copy link

andynash commented Dec 4, 2024

Just wanted to say I'm experiencing the same issue, all consents given/accepted, via every link I could find online and via the app, obviously including all those mentioned here.

Presumably this is resulting from a redirect to a non-HTTPS page, so perhaps there is a consent I have missed but I have looked extremely thoroughly multiple times.

What is needed it seems is some modification of the integration to expose the url causing the problem.

That's beyond me, but perhaps someone else has the skills. There are many other improvements needed to the integration too, some very simple (e.g. properly linking to the Guthub documentation and issues), some more involved (e.g. correctly defining sensors as boolean rather than text, which would be a breaking but important change).

Clearly this issue is therefore related to the fact that this integration no longer seems to be maintained, see #283.

Hopefully given the number of people using this integration is proportionate to the number of people driving supported cars, and someone somewhere can help, as the integration is unusable for me for now 🤞

It would also be helpful if those who say they have fixed permissions and now have things working could state what version of HA they are using. For me this happened after upgrading to 2024.12. Perhaps they are using an earlier version amd are unaffected by some change in 2024.12, perhaps not 🤷‍♂️

@etobi
Copy link

etobi commented Dec 4, 2024

I'm using HA 2024.11.3 and experiencing the same since 2 or 3 days.

@andynash
Copy link

andynash commented Dec 4, 2024

I'm using HA 2024.11.3 and experiencing the same since 2 or 3 days.

Thanks, that maybe rules out a change in HA 👍

@MCBrakel
Copy link

MCBrakel commented Dec 4, 2024

Thanks all,

This bit: "To resolve my problem, I removed consent for everything, saved that, and restored consent again."
Plus this bit: "I've deleted all the connected apps listed on https://id.vwgroup.io/."

And then reloading the application in HA solved this same issue on my side.

@waberc
Copy link

waberc commented Dec 4, 2024

It effectively looks like it comes from VW or from the underlaying python library as I face the same issue when using the weconnect-cli directly: tillsteinbach/WeConnect-cli#152

@ColinRobbins
Copy link
Contributor

My problem is that every time I logon to the vw web interface it asks for me to accept the terms and privacy. I press accept. All should be Ok.
but if I logout and back in again, I have accept them again.
So I wondering if there is a server issue at the VW end, not storing granted consent correctly?

@MCBrakel
Copy link

MCBrakel commented Dec 4, 2024

My problem is that every time I logon to the vw web interface it asks for me to accept the terms and privacy. I press accept. All should be Ok. but if I logout and back in again, I have accept them again. So I wondering if there is a server issue at the VW end, not storing granted consent correctly?

Maybe try use a different browser?

@JohanDonne
Copy link

JohanDonne commented Dec 5, 2024

Solution that worked for me: robinostlund/homeassistant-volkswagencarnet#683 (comment)

@ColinRobbins
Copy link
Contributor

Maybe try use a different browser?

No, that didn't work. However the change the country to "Albania" and then back again worked.
HaHa, VW marketing team in Albania will be congratulating themselves with all the new sales :-)

@andynash
Copy link

andynash commented Dec 5, 2024

Well this is weird- I made no changes yet overnight the integration started working again. Anyone else?

I guess there are two likely explanations: either VW have fixed something, or after my last attempt to accept terms (which in my case were already all accepted) perhaps I neglected to reload (and a reload took place for some reason in the meantime). I've tried this numerous times amd have definitely reloaded, and thought I did every time.

If this has happened only for me, then I suppose the latter is more likely.

If that does turn out to be the case, it reemphasises the need to expose what URL (and hopefully therefore the permission(s)) is causing this so a meaningful error can be generated, as fixing this currently seems to be a case of fumbling around in the dark. And that of course wastes of a lot of people's time.

Ps fyi at no point did I remove permissions for the app to reaccept them (though I did try turning off various permission switches on my.volkswagen.co.uk and then reenabling them), so that would suggest doing so is (in theory) overkill. The app continued to work throughout and never requested any permissions be confirmed, and neither did the website.

@bertalgoet
Copy link

ading the application in HA solved this same issue on m

For some reason this also fixed it for me, how bizar

@sven73a
Copy link

sven73a commented Dec 7, 2024

What fixed for me was changing the country to another country and then back the original country on https://id.vwgroup.io/landing-page

@distwave
Copy link

distwave commented Dec 7, 2024

Confirmed, it's a bug on Volkswagen consent management. If you try to login and always get the updated terms and conditions to accept, the consent is not being stored and that prevents the integration to do the login process.

As @sven73a and others report, going to the profile and changing your country to another one, accept the updated T&C, select your country again and accept the updated T&C for a last time seems to work, the consent is stored and you never get the prompt again, making the integration work as before.

@mpschr
Copy link

mpschr commented Dec 7, 2024

Just to be sure, it's not the billing address that needs to be changed to another country and back after logging in at https://id.vwgroup.io/landing-page. It is the Country and Region information

grafik

I'd mark this issue as fix #285

@sigvind
Copy link

sigvind commented Dec 9, 2024

Can confirm changing country as @mpschr showed via web worked for me too, moving to Sweden and back. There was a green note popping up each time at upper right, that country was successfully changed. Thanks for digging into this!

@andynash
Copy link

For me the changing country thing has not (so far) been necessary.

As previously mentioned, the integration began working again overnight - no idea precisely what triggered this.

However after a reboot of the HA server today it stopped working again, so I thought I'd try the country change after all.

Before I could do so, I was asked for two consents at the URL mentioned above. After accepting these I reloaded the integration and it is now working again.

So for me at least I still haven't needed to change country.

@Ged-fi
Copy link

Ged-fi commented Dec 18, 2024

I can confirm that I also had to change country in my profile and then change it back to get the consent to record properly on my VW profile.

Without this, I got the "consent" question on every login - so it clearly was not being recorded in my profile.

Interesting, because technically that is GDPR violation on VW's behalf.

@mattgruter
Copy link

Changing region/country in my profile and back worked for me as well. I followed the steps described here: robinostlund/homeassistant-volkswagencarnet#683 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests