python - 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
给检查 client.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)
推荐阅读
- javascript - 使用 `Observable` 代替 `$q.all`
- apache-spark - dstream 解析 JSON 并保存到 textFile:SparkStreaming
- google-app-maker - 如何在仪表板中生成状态值(计数)
- javascript - javascript映射不起作用
- javascript - 如何使用 laravel 在 javascript 中创建链接
- git - 有关如何为 yocto 进行 git 修订的信息
- php - 字典数组的非持久性检查
- android-studio - 发布到本地 maven 存储库的 AAR 中的 Android Studio 引用类
- python - flask API 查询项目,JSON
- windows - 您如何自动运行交互式 shell 的命令?