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

Don't get auth code in telegram #4156

Closed
3 tasks done
JackCat1 opened this issue Jul 22, 2023 · 3 comments
Closed
3 tasks done

Don't get auth code in telegram #4156

JackCat1 opened this issue Jul 22, 2023 · 3 comments

Comments

@JackCat1
Copy link

Code that causes the issue

tg_ses = TELETHON_DATA_FIELD + str(self.instance.pk)
client = TelegramClient(tg_ses, TELEGRAM_API_ID, TELEGRAM_API_HASH)
await client.connect()

if await client.is_user_authorized():
await client.disconnect()
return {'status':'is_auth'}
phone_hash = ''
try:
send_phone = await client.send_code_request(phone)

if send_phone.phone_code_hash:
    phone_hash = send_phone.phone_code_hash                

except errors.RPCError as e:
return {'status':'error', 'msg':e.message}
except Exception as e:
return {'status':'error', 'msg':'Авторизация не возможна'}
await client.disconnect()
return {'status':'OK', 'phone_code_hash':phone_hash}

Expected behavior

I'd like auth in TG. I do client.send_code_request(phone) and get auth code

Actual behavior

I'd like auth in TG. I do client.send_code_request(phone) and get "phone_code_hash" But code in telegram doesn't come. It happens sometimes. Especially, I often get this behavior in the evening. Has anyone experienced this?

Traceback

No response

Telethon version

1.24.0

Python version

3.9.16

Operating system (including distribution name and version)

Ubuntu 18.04.6 LTS

Other details

No response

Checklist

  • 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 an open duplicate.
  • I ran pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zip and triggered the bug in the latest version.
@Lonami
Copy link
Member

Lonami commented Jul 23, 2023

This behaviour likely happens from Telegram's side, and not Telethon, and therefore, there's probably nothing to fix in the library itself.

@Lonami Lonami closed this as completed Jul 23, 2023
@JackCat1
Copy link
Author

Do you know why this happens? Have you encountered this behavior before?

@Lonami
Copy link
Member

Lonami commented Jul 23, 2023

#3835 is currently pinned and this is a duplicate of it.

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

No branches or pull requests

2 participants