Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

error: connection_data["phone"] #19

Open
vhdm opened this issue Jan 11, 2022 · 12 comments
Open

error: connection_data["phone"] #19

vhdm opened this issue Jan 11, 2022 · 12 comments

Comments

@vhdm
Copy link

vhdm commented Jan 11, 2022

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'

@ttycelery
Copy link
Owner

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

vhdm commented Jan 11, 2022 via email

@rijumone
Copy link
Collaborator

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.

@ttycelery
Copy link
Owner

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

Checking this.

@ttycelery
Copy link
Owner

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

@rijumone
Copy link
Collaborator

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

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

@ttycelery
Copy link
Owner

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

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

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

reinier-millo commented Jan 31, 2022

@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

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

No branches or pull requests

4 participants