mmohades / Venmo

Venmo API client for Python
GNU General Public License v3.0
145 stars 43 forks source link

Added ability to read 2fa code from a file #35

Closed alexwilson1 closed 3 years ago

alexwilson1 commented 3 years ago

This code is mainly for headless scenarios (so the 2fa code does not have to be read from console). The optional argument can be used to specify the path to the text file (containing the 6 digit code), and the system will then poll this location until the file has been correctly read.

mmohades commented 3 years ago

I like the idea of having alternative ways of obtaining OTP. I think a more generic solution would be passing a callback that authentication process would use to obtain the OTP. If nothing is passed, then it'd do the CLI as before.

Basically, have an optional argument for the get_access_token method named otp_callback and set it to None by default. The callback signature would be accepting no arguments and returning a String representing OTP.

Then, pass the callback to the authentication API constructor, and set it to an instance variable like self.otp_callback = otp_callback or self.__ask_user_for_otp_password. During the authentication process, use self.otp_callback to obtain the OTP.

Please make sure to document it accordingly for all the methods and do validations and type hints as needed.

After making the changes you could call the method like this: Client.get_access_token(username='myemail@random.com', password='your password', otp_callback=some_function)

mmohades commented 3 years ago

Any updates?

alexwilson1 commented 3 years ago

I think creating a more generic way of doing this is a great idea and the implementation you have described seems ideal. However, I'm not sure if I'll have time to implement this soon. Happy for someone else to pick it up otherwise.

mmohades commented 3 years ago

Thanks for opening the PR and brining this to my attention! I'll add it for the next release. I'm gonna close this PR then.