Squachen / micloud

Library for connecting to xiaomi cloud.
MIT License
152 stars 18 forks source link

Cannot login #13

Open solvek opened 1 year ago

solvek commented 1 year ago

The installed version is 0.6 Trying commmand line from the example:

!micloud -d -u '<Email Login>' --country 'cn' --pretty The output: Error: no such option: -u

The code:

from micloud import MiCloud

mc = MiCloud("<Email>", "<Password>")
mc.login() # Returns false
token = mc.get_token() # Retruns None
device_list = mc.get_devices(country="cn")

The most recent command returns such error: ERROR:root:Cannot execute request. service token or userId missing. Make sure to login.

Just for information: I am running the code in Google Colab

solvek commented 1 year ago

Basically what I eventually need to achive just for my each device get information whether it is currently online (or when it was online recently) from my python script. Is it possible?

Squachen commented 1 year ago

Version 0.6 changed how the cli works and I've forgotten to update the documentation. Now you have to specify what command you want to run:

Usage: micloud [OPTIONS] COMMAND [ARGS]...

  Tool for fetching xiaomi cloud information.

Options:
  -d, --debug
  --help       Show this message and exit.

Commands:
  get-devices  Get device information, including tokens.
  miot         Commands for miotspec fetching.

Your example would be:

micloud get-devices -u <email> --pretty

or if you want the debug output:

micloud -d get-devices -u <email>

I'll update the documentation asap.

solvek commented 1 year ago

Thanks. Tried this command micloud get-devices

It asked for username then password. I provided both but then received error: Error: Got unexpected extra argument (get-devices)

Squachen commented 1 year ago

I cannot reproduce that error running Python 3.11.0 and micloud 0.6 installed by pip.

solvek commented 1 year ago

What basically is username for xiaomi? Will email work?

Squachen commented 1 year ago

Yes email should work. Also check if you are effected by issue #6 edit: wrong issue link

solvek commented 1 year ago

It seems on the login step 2 server returned unexpected json content.

{
   "notificationUrl":"https://account.xiaomi.com/identity/authStart?...&_locale=en_US",
   "result":"ok",
   "code":0,
   "captchaUrl":null,
   "description":"\u6210\u529f",
   "location":"",
   "securityStatus":16,
   "pwd":0,
   "child":0,
   "desc":"\u6210\u529f"
}

But it expects to have json attributes userId, ssecurity and so on.

Squachen commented 1 year ago

Seems to be a similar problem, did you try going to the "notificationUrl" in a browser as described in issue #6 ?

solvek commented 1 year ago

Seems to be a similar problem, did you try going to the "notificationUrl" in a browser as described in issue #6 ?

Yes, but the content in the page is different. image

I do verification and getting "ok" on web page but still login from python code does not work for me.

spicydonkey commented 1 year ago

I'm having the same problem as @solvek described. Completing the two factor authentification by following the url back steps in #6 didn't help. Specifically, when I run micloud again to login, it returns to the same situation.