d60 / twikit

Twitter API Scraper | Without an API key | Twitter Internal API | Free | Twitter scraper | Twitter Bot
https://twikit.readthedocs.io/en/latest/twikit.html
MIT License
1.45k stars 171 forks source link

Update login process #50

Closed valeriiisotnyk closed 7 months ago

valeriiisotnyk commented 7 months ago

Hi, Can you modify the login process so that, in situations requiring 2FA or a verification step, it throws an exception instead of prompting for input? If such an exception occurs, could we attempt to log in again, possibly passing the 2FA code directly into the login function? Alternatively, could you create a function that sets this code and initiates the login process? The current method, which falls back to an input prompt, cannot be automated.

https://github.com/d60/twikit/blob/main/twikit/client.py#L244 https://github.com/d60/twikit/blob/main/twikit/client.py#L258

d60 commented 7 months ago

Indeed, as you say, the authentication code should be able to be passed as an argument as well as an input. Currently that is not possible, but will be added in the future.

d60 commented 7 months ago

@valeriiisotnyk

I have uploaded an idea for a new login method to Gist. Three new args have been added: twofa_code, verification_code, and throw_exception. If throw_exception is set to True, an exception is thrown if a two-factor authentication code or verification code is required. And the 2FA code and verification code can be given as arguments. Please provide feedback if you have any other suggestions.

https://gist.github.com/d60/e79f556f761261d29bdc2a85032ef0de#file-1-py

valeriiisotnyk commented 7 months ago

@d60 I'll make the changes in my fork. Thank you