valueerror:您还需要提供一个phone_code_hash


from telethon.sync import TelegramClient
from telethon.tl.functions.messages import GetDialogsRequest
from telethon.tl.types import InputPeerEmpty
api_id = XXXXXXX
api_hash = 'XXXXXXXXXXXXXXXXXXXXXXXX'
phone = '+XXXXXXXXXXX'
client = TelegramClient(phone, api_id, api_hash)
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone)
phone_code_hash = client.send_code_request(phone).phone_code_hash

client = TelegramClient(phone, api_id, api_hash)
client.connect()
client.sign_in(phone, input('Enter the code: '))

我如何通过phone_code_hash将它传递给检查客户端。sign_in(phone, input('Enter the code: '))

如果不插入缓存,出现错误valueerror: you also need to provide a phone_code_hash.

必须在第五个条目中输入哈希

client = TelegramClient(phone, api_id, api_hash)
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone)
phone_code_hash = client.send_code_request(phone).phone_code_hash
client = TelegramClient(phone, api_id, api_hash)
client.connect()
client.sign_in(phone, input('Enter the code: '), phone_code_hash=phone_code_hash)

我从这里得到了答案https://github.com/LonamiWebs/Telethon/blob/9445d2ba535ed7d214a7e6e68b85e7f3af1a690e/telethon/telegram_client.py#L141-L149

相关内容

最新更新