I’m trying to make api auth with telethon work. I’m sending request to endpoint where telegram client is initialized and trying to send code request to telegram. But there is input() and I didn’t find any solution to pass code as variable
@router.get('/code')
async def send_code_request(phone: str):
client = get_telegram_client(phone)
await client.start(phone)
return {'msg': 'code sent'}
2
Answers
I found easier solution, but there is one con - when authorizing via session sign_in() method is requiring to execute send_code_request() method first so there is will be 2 same code messages
I’m assuming you’re using
.start()
for that..start()
accepts a callback that is by defaultinput()
you can pass your own input like so.client.start(code_callback=your_callback)
and your callback should should return the code.This can all be found here in the start docs