Use getpass instead input for the password

Lonami 2017-09-25 12:45:53 +02:00
parent d5451dfa15
commit 8ee21b606a

@ -1,13 +1,14 @@
If you have Two Factor Authorization (from now on, 2FA) enabled on your account, calling `.sign_in` will raise a `SessionPasswordNeededError`. When this happens, just `.sign_in()` again with a `password=`: If you have Two Factor Authorization (from now on, 2FA) enabled on your account, calling `.sign_in` will raise a `SessionPasswordNeededError`. When this happens, just `.sign_in()` again with a `password=`:
```python ```python
import getpass
from telethon.errors import SessionPasswordNeededError from telethon.errors import SessionPasswordNeededError
client.sign_in(phone) client.sign_in(phone)
try: try:
client.sign_in(code=input('Enter code: ')) client.sign_in(code=input('Enter code: '))
except SessionPasswordNeededError: except SessionPasswordNeededError:
client.sign_in(password=input('Enter password: ')) client.sign_in(password=getpass.getpass())
``` ```
## Enabling 2FA ## Enabling 2FA