Core: BMW Connected Drive: Authentication failed. Maybe your password is invalid?

Created on 20 Oct 2020  路  18Comments  路  Source: home-assistant/core

The problem


As of today, the BMW Connected Drive integration is giving authentication errors. However, my password has not changed and I鈥檓 still able to login to the app and website using the same credentials.

Environment

  • Home Assistant Core release with the issue: 0.116.4
  • Last working Home Assistant Core release (if known): 0.116.4
  • Operating environment (OS/Container/Supervised/Core): HassOS 4.14
  • Integration causing this issue: bmw_connected_drive
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/bmw_connected_drive/

Problem-relevant configuration.yaml

# Example configuration.yaml entry
bmw_connected_drive:
  name:
    username: !secret bmw_username
    password: !secret bmw_password
    region: rest_of_world

Traceback/Error logs

2020-10-20 19:26:24 ERROR (SyncWorker_15) [bimmer_connected.account] Authentication failed. Maybe your password is invalid?
2020-10-20 19:26:24 ERROR (SyncWorker_15) [bimmer_connected.account] ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 403, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/bimmer_connected/account.py", line 111, in _get_oauth_token
    response = self.send_request(url, data=data, headers=headers, allow_redirects=False,
  File "/usr/local/lib/python3.8/site-packages/bimmer_connected/account.py", line 154, in send_request
    response = requests.post(url, headers=headers, data=data, allow_redirects=allow_redirects,
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
2020-10-20 19:26:30 ERROR (MainThread) [homeassistant.setup] Error during setup of component bmw_connected_drive
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 403, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
    response.begin()
  File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.8/http/client.py", line 276, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/bimmer_connected/account.py", line 111, in _get_oauth_token
    response = self.send_request(url, data=data, headers=headers, allow_redirects=False,
  File "/usr/local/lib/python3.8/site-packages/bimmer_connected/account.py", line 154, in send_request
    response = requests.post(url, headers=headers, data=data, allow_redirects=allow_redirects,
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/__init__.py", line 52, in setup
    accounts.append(setup_account(account_config, hass, name))
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/__init__.py", line 80, in setup_account
    cd_account = BMWConnectedDriveAccount(username, password, region, name, read_only)
  File "/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/__init__.py", line 127, in __init__
    self.account = ConnectedDriveAccount(username, password, region)
  File "/usr/local/lib/python3.8/site-packages/bimmer_connected/account.py", line 61, in __init__
    self._get_vehicles()
  File "/usr/local/lib/python3.8/site-packages/bimmer_connected/account.py", line 226, in _get_vehicles
    self._get_oauth_token()
  File "/usr/local/lib/python3.8/site-packages/bimmer_connected/account.py", line 117, in _get_oauth_token
    raise OSError(msg) from exception
OSError: Authentication failed. Maybe your password is invalid?

Additional information

Appears to be related to https://github.com/bimmerconnected/bimmer_connected/issues/208

bmw_connected_drive

Most helpful comment

Until the hotfix is in 0.117, you can use our custom component. Download at https://github.com/bimmerconnected/ha_custom_component/releases/tag/20201022.1 or via HACS ;)

__Please note that it includes a config flow for the component which is not part of the main HA branch. So if you go the custom component way you need to stay on it until home-assistant/core#39585 is merged!!__

All 18 comments

Hey there @gerard33, @rikroe, mind taking a look at this issue as its been labeled with an integration (bmw_connected_drive) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

Whilst Audi Connect is a custom component not fully integrated in Home Assistant, it is exhibiting the same behaviour.
I have an Audi, my colleague has a BMW and both integrations failed at almost the same time with almost the same error, could it be an authentication problem?

https://github.com/arjenvrh/audi_connect_ha/issues/48

Shunts...

There is an issue with the BMW API authentication. It might just start to work again or a little more reverse engineering is needed to understand the changes to the API.

It is also being tracked at bimmerconnected/bimmer_connected#208 and will occur also if you're not using HA but the library directly.

Seems that BMW has changed something to its login procedure. When opening the app yesterday (iphone) I had to create a pin code.

I changed the account.py as follows: https://github.com/bimmerconnected/bimmer_connected/compare/master...rikroe:fix/connection_refused
Issue is solved for the moment and Home Assistant can use the integration again.
But seems to be a workaround...

a workaround

I confirm that this workaround is working

Is the update making it to the next HA release?

bimmer_connected 0.7.8 has been published to PyPI.
When using HA you should now be able to manually update by pip3 install bimmer_connected==0.7.8. I will create a PR for HA later today after coming back from work.

Also, for not having HA re-downloading 0.7.7 on restart, you have to change the following file (location in the HA docker image) and change to 0.7.8:
/usr/src/homeassistant/homeassistant/components/bmw_connected_drive/manifest.json

I'm running HA in docker on raspbian, how can I update it on that in the mean time?

  • SSL into raspbian
  • Find the container ID of your docker container running HA (docker ps)
  • Go into the docker's bash (docker exec -it YOURCONTAINERID /bin/bash
  • do the upgrade as described above or navigate to the file and change the lines to have the workaround as described in my link above

Update: An upgrade to 0.7.8 doesnt solve the problem. The workaround does

Thanks but where about's is the file:
image

/usr/local/lib/python3.8/site-packages/bimmer-connected

(you see that in your logs, too)

Update: An upgrade to 0.7.8 doesnt solve the problem.

That's probably because HA still uses 0.7.7 as that is in the manifest.json of the BMW ConnectedDrive integration.
Can you bump the version in that file and try again?
I have 0.7.8 working fine here with HA with the method described above.

Yes just updating to 0.7.8 did not fix for me either but updating those files did.
Many thanks 馃憤

Until the hotfix is in 0.117, you can use our custom component. Download at https://github.com/bimmerconnected/ha_custom_component/releases/tag/20201022.1 or via HACS ;)

__Please note that it includes a config flow for the component which is not part of the main HA branch. So if you go the custom component way you need to stay on it until home-assistant/core#39585 is merged!!__

0.7.8 did not fix login issue for "china".
HA 0.117.1 did not fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

soldag picture soldag  路  143Comments

kdschlosser picture kdschlosser  路  374Comments

Ciqsky picture Ciqsky  路  129Comments

sagilo picture sagilo  路  130Comments

abouelric picture abouelric  路  165Comments