Closed ysomad closed 2 years ago
Checklist
pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip
I'm trying to implement telegram auth with fastapi and getting 2 sms with force_sms = True
Code that causes the issue
async def get_telegram_client(session: str = None) -> TelegramClient: return TelegramClient( StringSession(session), api_id=settings.TELEGRAM_API_ID, api_hash=settings.TELEGRAM_API_HASH ) @router.post('/code') async def send_authorizarion_code(payload: TelegramSendCode): client = await get_telegram_client() await handle_send_code_request(client, payload) session = client.session.save() return {'phone': payload.phone, 'session': session} async def handle_send_code_request( client: TelegramClient, payload: TelegramSendCode) -> Union[None, JSONResponse]: await client.connect() try: await client.send_code_request( payload.phone, force_sms=payload.force_sms) except FloodWaitError as e: return JSONResponse(status_code=420, content={ 'phone': e.request.phone_number, 'cooldown_seconds': e.seconds }) except PhoneNumberInvalidError: return JSONResponse(status_code=406, content={'phone': payload.phone})
Requested 2 codes and there is the result
Checklist
pip install -U https://github.com/LonamiWebs/Telethon/archive/master.zip
and triggered the bug in the latest version.I'm trying to implement telegram auth with fastapi and getting 2 sms with force_sms = True
Code that causes the issue