Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from
Closed

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

wants to merge 2 commits into from

Conversation

alexwilson1
Copy link
Contributor

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
Copy link
Owner

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='[email protected]', password='your password', otp_callback=some_function)

@mmohades
Copy link
Owner

mmohades commented Apr 5, 2021

Any updates?

@alexwilson1
Copy link
Contributor Author

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
Copy link
Owner

mmohades commented Apr 9, 2021

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.

@mmohades mmohades closed this Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants