Skip to content

Commit

Permalink
Merge pull request #3 from noslouch/feat/support-2fa
Browse files Browse the repository at this point in the history
feat: support two factor auth
  • Loading branch information
loganwilliams authored Jul 20, 2021
2 parents 2156420 + 31b5905 commit a06ea0e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions telegram-phone-validation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/local/bin/python3
from telethon import TelegramClient, events, sync
from telethon import TelegramClient, errors, events, sync
from telethon.tl.types import InputPhoneContact
from telethon import functions, types
from dotenv import load_dotenv
import argparse
import os
from getpass import getpass

load_dotenv()

Expand Down Expand Up @@ -57,6 +58,10 @@ def user_validator():
client.connect()
if not client.is_user_authorized():
client.send_code_request(PHONE_NUMBER)
client.sign_in(PHONE_NUMBER, input('Enter the code (sent on telegram): '))
try:
client.sign_in(PHONE_NUMBER, input('Enter the code (sent on telegram): '))
except errors.SessionPasswordNeededError:
pw = getpass('Two-Step Verification enabled. Please enter your account password: ')
client.sign_in(password=pw)
user_validator()
print(result)

0 comments on commit a06ea0e

Please sign in to comment.