lc-at / kyros

Python wrapper for WhatsApp Web API websocket communication (based on https://github.com/sigalor/whatsapp-web-reveng)
MIT License
107 stars 27 forks source link

error: connection_data["phone"] #19

Open vhdm opened 2 years ago

vhdm commented 2 years ago

dear @p4kl0nc4t please help me

my code is: ` # create the Client instance using create class method whatsapp = await kyros.Client.create()

# do a QR login
qr_data, scanned = await whatsapp.qr_login()

# generate qr code image
qr_code = pyqrcode.create(qr_data)
print(qr_code.png('code.png', scale=1, module_color=[0, 0, 0, 128], background=[0xff, 0xff, 0xff]))
# print(qr_code.terminal(quiet_zone=0))`

after scan qr code, occur this error:

Traceback (most recent call last): File "init.py", line 41, in <module> asyncio.run(main()) File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.8/asyncio/base_events.py", line 612, in run_until_complete return future.result() File "init.py", line 26, in main await scanned File "/tmp/w/lib/python3.8/site-packages/kyros/client.py", line 103, in wait_qr_scan self.phone_info = connection_data["phone"] KeyError: 'phone'

lc-at commented 2 years ago

Well, that's bad. It seems like the WhatsApp Web API has quite changed. I am busy now, I will take a look on that later.

vhdm commented 2 years ago

thanks

On Tue, Jan 11, 2022 at 6:18 PM Faiz Jazadi @.***> wrote:

Well, that's bad. It seems like the WhatsApp Web API has quite changed. I am busy now, I will take a look on that later.

— Reply to this email directly, view it on GitHub https://github.com/p4kl0nc4t/kyros/issues/19#issuecomment-1010036231, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADL6RELGKNRHM2CKZ43HCRLUVQ7MJANCNFSM5LWK7CSA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

-- i digit web design ;)

rijumone commented 2 years ago

If it helps, the value of connection_data on ln 102 of /path/to/venv/lib/python3.9/site-packages/kyros/client.py is:

{'type': 'upgrade_md_prod', 'version': '2.2126.11'}

At least for me. The dictionary does not contain the phone key, hence the error. I am facing the same error.

lc-at commented 2 years ago

I don't seem to be able to reproduce this issue. i can't reproduce

@rijumone Your connection_data value looks bad. I think this issue is much more seriuous than I initially thought. The connection_data object should contain many important details as specified in here. The values especially the tokens are mandatory for kyros to be working properly.

Below is my connection_data value. image

rijumone commented 2 years ago

Checking this.

lc-at commented 2 years ago

I can't reproduce the error. Is it related to this?

rijumone commented 2 years ago

I can't reproduce the error. Is it related to this?

I think, yes! The message received (lacking the phone key) is identical and even my WA a/c is multi-device enabled as mentioned in the linked issue. Is your WA a/c multi-device enabled? I am trying to check if I have access to a WA a/c with multi-device disabled.

rijumone commented 2 years ago

I procured a device with a W/A a/c which has never been logged into W/A (at least I believe so, definitely never been logged in as a multi-device). Now, while the library itself does not throw any errors, the script just exits. I am checking the code for the same as to why this is happening. Attaching a screenshot of the same. image

lc-at commented 2 years ago

I have similar results when I scanned it using a multi-device enabled WhatsApp (produces no output, just exits). Try setting the logger mode to DEBUG.

logging.getLogger("kyros").setLevel(logging.DEBUG)

I found out that the WhatsApp websocket server closed the connection right after the QR scan. It seems that many things have to be adjusted. Baileys and whatsmeow both supports multi-device. I think they can be used as a reference.

rijumone commented 2 years ago

I have similar results when I scanned it using a multi-device enabled WhatsApp (produces no output, just exits). Try setting the logger mode to DEBUG.

logging.getLogger("kyros").setLevel(logging.DEBUG)

I found out that the WhatsApp websocket server closed the connection right after the QR scan. It seems that many things have to be adjusted. Baileys and whatsmeow both supports multi-device. I think they can be used as a reference.

@p4kl0nc4t Apologies for the late response, last week has been incredibly busy. I am still getting the same traceback.

Traceback (most recent call last):
  File "/home/rijumone/Kitchen/kyros/main.py", line 43, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/rijumone/Kitchen/kyros/main.py", line 28, in main
    await scanned
  File "/home/rijumone/Kitchen/kyros/.venv/lib/python3.9/site-packages/kyros/client.py", line 102, in wait_qr_scan
    self.phone_info = connection_data["phone"]
KeyError: 'phone'

Printing connection_data on ln 101 in file: .venv/lib/python3.9/site-packages/kyros/client.py still outputs:

{'type': 'upgrade_md_prod', 'version': '2.2126.11'}

There is no phone key which is being accessed on ln 102.

I am checking the issue you linked previously. Do you have any suggestion?

rijumone commented 2 years ago

@p4kl0nc4t I was able to have a successful login using this particular branch of this repo.

Though what a successful login means, I am still investigating. I was able to scan the QR code on my phone and it didn't error out. Terminal spewed out some debug text showing my contacts data.

This is in TS which I am not familiar with. Suggestions welcome.

reinier-millo commented 2 years ago

@p4kl0nc4t I was able to have a successful login using this particular branch of this repo.

Though what a successful login means, I am still investigating. I was able to scan the QR code on my phone and it didn't error out. Terminal spewed out some debug text showing my contacts data.

This is in TS which I am not familiar with. Suggestions welcome.

I can help reviewing it, i have worked with TS. I'm using WA Business and it's working fine on my Android phone (I have testes develop branch). I don't have tested on WA multidevice, maybe with the support of multiple devices maybe there are some changes, but i don't think so because phone contains only the information of the real device (battery, os, wa version, model, manufactures) and the support of multiple device allow up to 4 instances of Web WA, but only 1 phone.

Maybe the field was removed in new versions of WA because phone can be offline or off. In any case i think that it can be ignored.

If you can share the steps to reproduce the error it would help me