You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error is in the library's code, and not in my own.
I have searched for this issue before posting it and there isn't a duplicate.
I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip and triggered the bug in the latest version.
Code that causes the issue
fromtelethonimportTelegramClientimportasyncioapi_id=""api_hash=""defdisplay_url_as_qr(url):
print(url)
pass# do whatever to show url as a qr to the userasyncdefqr_login():
client=TelegramClient('test', api_id, api_hash)
awaitclient.connect()
qr_login=awaitclient.qr_login()
display_url_as_qr(qr_login.url)
# Important! You need to wait for the login to complete!awaitqr_login.wait()
print(awaitclient.get_me())
loop=asyncio.get_event_loop()
loop.run_until_complete(qr_login())
Problem
When you scan the generated qr code, the application on the phone crashes: (click to open gif)
phone.mp4
But not always: (click to open gif)
phone_2.mp4
What's the problem?
The problem is that "qrlogin.py" uses base64 -> base64.b64encode(), as I understand it should be base64url -> urlsafe_b64encode().
I found url64 library, it has this code:
Thank you for the detailed report. Would you like to send a pull request? As I understand it, the changes needed are using base64.urlsafe_b64encode and adding .rstrip('=').
Checklist
pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip
and triggered the bug in the latest version.Code that causes the issue
Problem
![windows](https://user-images.githubusercontent.com/46572469/122671990-f264e280-d1d1-11eb-9641-bf8bfd3782d0.gif)
When you scan the generated qr code, the application on the phone crashes: (click to open gif)
phone.mp4
But not always: (click to open gif)
![windows_2](https://user-images.githubusercontent.com/46572469/122673256-3f4bb780-d1d8-11eb-91ba-35fd67e50f13.gif)
phone_2.mp4
What's the problem?
The problem is that "qrlogin.py" uses base64 -> base64.b64encode(), as I understand it should be base64url -> urlsafe_b64encode().
I found url64 library, it has this code:
and it does just fine:
(I'm not suggesting that add this code to the library, it's just an example of how I fixed it)
What has changed?
Old:
New:
The text was updated successfully, but these errors were encountered: