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

Error: Unable to log in, check credentials #50

Closed
robbinonline opened this issue Dec 1, 2020 · 57 comments · Fixed by #131
Closed

Error: Unable to log in, check credentials #50

robbinonline opened this issue Dec 1, 2020 · 57 comments · Fixed by #131
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@robbinonline
Copy link

I keep having the error: keyError: 'ssecurity'

What did I try to fix

  • use my account id instead of e-mailadres. Select cn or de server.
  • Create a new account factory reset my vacuum and add it to the new account. Mainland setting china so for the config country cn and try the new mailadres and account id.

Keep having this error, on my iPhone I can loggin with email I also have a dev android phone also possible to login with mail or id.

Someone suggestions?

@PiotrMachowski PiotrMachowski self-assigned this Dec 1, 2020
@PiotrMachowski
Copy link
Owner

The problem might be caused by an expired token, I plan to add a fix for it.

@robbinonline
Copy link
Author

Is there something I can try now?

@PiotrMachowski
Copy link
Owner

I don't think so. Does everything work after HA restart?

@robbinonline
Copy link
Author

No how often I restart I keep looking at the ssecurity error

@PiotrMachowski
Copy link
Owner

You can check if this tool works: Tokens extractor

@robbinonline
Copy link
Author

robbinonline commented Dec 1, 2020

Yes that works fine.

Devices found for country "cn":

   NAME:  Robot vacuum
   ID:    2596xxxxx
   IP:    10.0.0.156
   TOKEN: 636xxxxxxxx51
   MODEL: roborock.vacuum.s5

@robbinonline
Copy link
Author

After running the tokens extractor from the same host as my home assistant it works fine now :)
Looks like the IP is now whitelisted or something.

@PiotrMachowski
Copy link
Owner

That's weird

@Paradoxx82
Copy link

Paradoxx82 commented Dec 3, 2020

Hi! I have exactly the same problem, it started a couple of days ago. I will also be very grateful for the solution!

@Paradoxx82
Copy link

For information - it worked again today, but I did not change anything.

@comedido
Copy link

Same problem here: KeyError: 'ssecurity'

I used 'Tokens extractor' in another machine in the network and I was able to log in and retrieve the token that I am trying to use in hassio. I am able to control the vacuum using another component but not this one.

I will wait a few days as it apparently worked for others...

@Addovej
Copy link

Addovej commented Dec 17, 2020

Getting same error:
2020-12-17 16:55:44 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.xiaomi_cloud_map_extractor fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update raise exc File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 175, in update File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 88, in login File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 65, in login_step_2 KeyError: 'ssecurity'

@PiotrMachowski PiotrMachowski added the bug Something isn't working label Dec 19, 2020
@Irritat0r
Copy link

Same here, just moved from Rasperry pi to a Ondroid n2+.
Everyting worked before but now i get the same problem as this thread.

2021-01-01 11:59:36 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.my_vacuum_camera fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
raise exc
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 177, in update
self._logged = self._connector.login()
File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 88, in login
return self.login_step_1() and self.login_step_2() and self.login_step_3()
File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 65, in login_step_2
self._ssecurity = json_resp["ssecurity"]
KeyError: 'ssecurity'

@michelotten
Copy link

michelotten commented Jan 5, 2021

Having the same issue as described above on a Synology NAS, with Home Assistant running in a Docker container.
Not sure if this is related, but with the Cloud Token Extractor python script running on the same NAS I'm getting error message 'Incorrect login', while the Windows script on my laptop is working fine.

Edit: I tried logging in with email address and user ID, both with same result.

@PiotrMachowski
Copy link
Owner

Please check if problem still exists in v1.0.2

@michelotten
Copy link

Updated to v1.0.2, now getting the following errors in my Home Assistant:

Logger: custom_components.xiaomi_cloud_map_extractor.camera
Source: custom_components/xiaomi_cloud_map_extractor/camera.py:179
Integration: xiaomi_cloud_map_extractor (documentation)
First occurred: 15:05:10 (18 occurrences)
Last logged: 15:06:36

Unable log in
Logger: homeassistant.helpers.entity
Source: custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py:176
First occurred: 15:05:10 (18 occurrences)
Last logged: 15:06:36

Update for camera.xiaomi_cloud_map_extractor fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 181, in update
    self._country = self._connector.get_country_for_device(self._vacuum.ip, self._vacuum.token)
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 94, in get_country_for_device
    devices = self.get_devices(country)
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 138, in get_devices
    return self.execute_api_call(url, params)
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 159, in execute_api_call
    signed_nonce = self.signed_nonce(nonce)
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 176, in signed_nonce
    hash_object.update(base64.b64decode(self._ssecurity) + base64.b64decode(nonce))
  File "/usr/local/lib/python3.8/base64.py", line 80, in b64decode
    s = _bytes_from_decode_data(s)
  File "/usr/local/lib/python3.8/base64.py", line 45, in _bytes_from_decode_data
    raise TypeError("argument should be a bytes-like object or ASCII "
TypeError: argument should be a bytes-like object or ASCII string, not 'NoneType'

@comedido
Copy link

comedido commented Jan 10, 2021

Latest version resolved my log in issues
[EDIT] Still failling:

Logger: homeassistant.helpers.entity
Source: custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py:176
First occurred: 16:19:05 (2 occurrences)
Last logged: 16:19:15

Update for camera.xiaomi_cloud_map_extractor fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
    raise exc
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/xiaomi_cloud_map_extractor/camera.py", line 181, in update
    self._country = self._connector.get_country_for_device(self._vacuum.ip, self._vacuum.token)
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 94, in get_country_for_device
    devices = self.get_devices(country)
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 138, in get_devices
    return self.execute_api_call(url, params)
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 159, in execute_api_call
    signed_nonce = self.signed_nonce(nonce)
  File "/config/custom_components/xiaomi_cloud_map_extractor/xiaomi_cloud_connector.py", line 176, in signed_nonce
    hash_object.update(base64.b64decode(self._ssecurity) + base64.b64decode(nonce))
  File "/usr/local/lib/python3.8/base64.py", line 80, in b64decode
    s = _bytes_from_decode_data(s)
  File "/usr/local/lib/python3.8/base64.py", line 45, in _bytes_from_decode_data
    raise TypeError("argument should be a bytes-like object or ASCII "
TypeError: argument should be a bytes-like object or ASCII string, not 'NoneType'

@PiotrMachowski
Copy link
Owner

Can you check the latest commit on master (not included in v1.0.3)? It will not solve the problem, but there will be no more exceptions in logs

@michelotten
Copy link

Hi,

That's right. It's now just showing the following:

Logger: custom_components.xiaomi_cloud_map_extractor.camera
Source: custom_components/xiaomi_cloud_map_extractor/camera.py:181
Integration: xiaomi_cloud_map_extractor (documentation)
First occurred: 16:43:55 (1 occurrences)
Last logged: 16:43:55

Unable to log in, check credentials

@PiotrMachowski
Copy link
Owner

@michelotten great, thanks! From the next release only first failed login attempt in series will be logged in logs

@PiotrMachowski PiotrMachowski changed the title KeyError: 'ssecurity' Error: Unable to log in, check credentials Jan 12, 2021
@michelotten
Copy link

@PiotrMachowski, is there anything I can still try in getting this issue sorted?

@PiotrMachowski
Copy link
Owner

@michelotten it's hard to say, it seems that the issue is somewhere outside my code, maybe it is caused by versions of dependencies... Can you provide some information about python version/dependencies versions?

@michelotten
Copy link

@PiotrMachowski My HomeAssistant Docker container is using Python 3.8.7. Which dependencies are you interested in? I can look these up.

@eksp0ha0akk
Copy link

eksp0ha0akk commented Mar 14, 2021

vac
Xiaomi Cloud Map Extractor v1.0.6
installed through HACS


Logger: custom_components.xiaomi_cloud_map_extractor.camera
Source: custom_components/xiaomi_cloud_map_extractor/camera.py:182
Integration: xiaomi_cloud_map_extractor (documentation)
First occurred: 11:16:23 (1 occurrences)
Last logged: 11:16:23

Unable to log in, check credentials

  - platform: xiaomi_cloud_map_extractor
    host: 192.168.1.85
    token: !secret vacuum_token
    username: email@gmail.com
    password: pass
    name: "My Vacuum Camera"
    draw: ['all']
    attributes:
      - calibration_points

Xiaomi Mi Robot 1S


why can't I log into the cloud?
What can I try to do?
password login is exactly correct.

@PiotrMachowski
Copy link
Owner

Please check your credentials using token extractor

@eksp0ha0akk
Copy link

Please check your credentials using token extractor

username and password copied from config in token extractor
vac1

@PiotrMachowski
Copy link
Owner

@SerialVelocity, @Ton1965 Did you have to do anything using URL from stage 1 or just stage 2 is needed?

@SerialVelocity
Copy link

Afaik, just stage 2. Might be worth printing something about having to use the same external IP address as Home Assistant though since that is where most people will hit this bug (if you use the same IP, someone logging in to the website will whitelist the IP for example)

@PiotrMachowski
Copy link
Owner

@SerialVelocity so user just have to go to URL provided in notificationUrl from a device that has the same public IP as HA and follow steps on the website and map extraction starts to work without any additional actions?

@Ton1965
Copy link

Ton1965 commented Jun 11, 2021

I have the same experience. Stage two only was needed. I just copied it to my browser address box and it asked me whether I wanted to be sent a confirmation short message or E-mail. After I got the message I just entered the code they sent me and map extraction started to work. It did not even require HA reloading.

@PiotrMachowski
Copy link
Owner

@SerialVelocity, @Ton1965 Thank you!

@Ton1965
Copy link

Ton1965 commented Jun 16, 2021

One more comment here.

I have encountered this re-authentication request from Xiaomi once more today. The latest cloud extractor version does a good job of putting the required URL into the log (thanks a lot for that). The only problem is it now does it too often. I had several thousands of these messages when I noticed it. I have restarted my HA and got 29 messages in three and a half minutes! Seems too much to me. And probably such often attempts of authentication will make Xiaomi unhappy as well. Besides that it looks like you need the latest URL, they get stale pretty fast. And it is difficult to locate and use it if they are updated that fast.

So I have a suggestion: put just a single message into the log and stop authentication attempts after the first failure. New attempt needs to be made only if really necessary like a user trying to view the corresponding UI card.

@PiotrMachowski
Copy link
Owner

PiotrMachowski commented Jun 16, 2021

@Ton1965 thank you for your feedback, that is something that definitely has to be done. Expiration period of a link has also be taken into account

I have created a dedicated issue: #135

@alexlopezcifuentes
Copy link

I have been experiencing the same issue also. The map extracting was working smooth and now it's unable to login, neither the token extractor. From where should I extract the 2FA link? Is it something that I have to extract from the token extractor? I can not see the link in Home Assistant logs...

@PiotrMachowski
Copy link
Owner

@alexlopezcifuentes 2FA link should be in HA logs. What response do you get in extractor?

@alexlopezcifuentes
Copy link

@PiotrMachowski I'm getting this in the complete HA log:
2021-06-22 19:53:10 ERROR (SyncWorker_2) [custom_components.xiaomi_cloud_map_extractor.camera] Unable to log in, check credentials

I'm using currently v2.0.2 which I believe is the last one.

@PiotrMachowski
Copy link
Owner

@alexlopezcifuentes how about token extractor?

@alexlopezcifuentes
Copy link

image

Same thing it seems... I have changed the HA Logger to see if it was something related to my own configuration of the Logger output but I still see the error but not the 2FA link.

@PiotrMachowski
Copy link
Owner

@alexlopezcifuentes Have you made some changes in your network setup?

@alexlopezcifuentes
Copy link

@PiotrMachowski No, I haven't. Everything is as it was a few weeks ago when the map extraction was properly running...

@PiotrMachowski
Copy link
Owner

@alexlopezcifuentes Have you added PiHole/AdGuard or Cloudflare DNS?

If not, can you try to manually run python version of tokens extractor and add print(response.text) after line 42, line 63 and line 87?

@UraniumDonut
Copy link

Hey there, I have the same issue and have added the print(response.text) lines. I have pihole disabled and no other DNS. This is the output:

Logging in... &&&START&&&{"serviceParam":"{\"checkSafePhone\":false,\"checkSafeAddress\":false,\"lsrp_score\":0.0}","qs":"%3Fsid%3Dxiaomiio%26_json%3Dtrue","code":70016,"description":"登录验证失败","securityStatus":0,"_sign":"0psXfr43eNI0IX6q9Suk3qWbRqU=","sid":"xiaomiio","result":"error","captchaUrl":null,"callback":"https://sts.api.io.mi.com/sts","location":"https://account.xiaomi.com/fe/service/login?_json=true&sid=xiaomiio&qs=%253Fsid%253Dxiaomiio%2526_json%253Dtrue&callback=https%3A%2F%2Fsts.api.io.mi.com%2Fsts&_sign=0psXfr43eNI0IX6q9Suk3qWbRqU%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=","pwd":0,"desc":"登录验证失败"} Traceback (most recent call last): File "C:\UserData\z00478ma\OneDrive - Siemens AG\Desktop\stuff\token_extractor\token_extractor.py", line 221, in <module> logged = connector.login() File "C:\UserData\z00478ma\OneDrive - Siemens AG\Desktop\stuff\token_extractor\token_extractor.py", line 102, in login if self.login_step_2(): File "C:\UserData\z00478ma\OneDrive - Siemens AG\Desktop\stuff\token_extractor\token_extractor.py", line 64, in login_step_2 print(response.text) UnboundLocalError: local variable 'response' referenced before assignment
@PiotrMachowski

@alexlopezcifuentes
Copy link

@alexlopezcifuentes Have you added PiHole/AdGuard or Cloudflare DNS?

If not, can you try to manually run python version of tokens extractor and add print(response.text) after line 42, line 63 and line 87?

I have not added PiHole or AdGuard either. Hopefully this weekend I can find some time to try the Python version of the Extractor and see the output of print that lines.

@SerialVelocity
Copy link

@UraniumDonut It looks like you might have placed the second print statement in the wrong place? Each one must be placed after the response = line

@PiotrMachowski
Copy link
Owner

@UraniumDonut @SerialVelocity I have prepared a version with prints: link

@UraniumDonut
Copy link

Suprise suprise. For some obscure reason your updated version worked perfectly (even with a more verbose output). Thank you!

@alexlopezcifuentes
Copy link

alexlopezcifuentes commented Aug 24, 2021

@PiotrMachowski Sorry for the delay but it has been impossible for me to check this until now. I used your Token Extractor script with prints version and this is the output I'm getting:

image

I'm still not able to logging neither here nor in HA.

@PiotrMachowski
Copy link
Owner

@alexlopezcifuentes does these credentials work in Xiaomi Home app?

@alexlopezcifuentes
Copy link

alexlopezcifuentes commented Aug 24, 2021

I have found the problem. Nothing to do with your software but It was like chasing a ghost.

It turns out that my old password (the one I have been using for years) contained the word "xiaomi" (I know, not the best approach for a password haha). I changed it from the app and I discovered that Xiaomi now does not enable the use of the word "xioami" in the passwords. I suppose that the account was somehow "blocked"...

I'm trying with a new password in HA but at least the Token Extractor is working now.

Thanks!

@PiotrMachowski
Copy link
Owner

@alexlopezcifuentes
Copy link

Working smoothly also in HA! Thanks @PiotrMachowski

@PiotrMachowski
Copy link
Owner

PiotrMachowski commented Aug 24, 2021

I'm glad you got it working 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.