mirror of
				https://github.com/LonamiWebs/Telethon.git
				synced 2025-11-04 01:47:27 +03:00 
			
		
		
		
	Use getpass instead input for the password
							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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user