Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get MFA code for a TOTP String, right now
#!/usr/bin/env python
# https://github.com/pyotp/pyotp
import pyotp
import argparse
parser = argparse.ArgumentParser(description='Get the TOTP code, for an MFA string, right now.')
parser.add_argument('mfa_string', metavar='mfa_string', type=str, help='The MFA string to get the current totp code for.')
args = parser.parse_args()
mfa_string = args.__dict__["mfa_string"]
totp = pyotp.TOTP(mfa_string)
print(totp.now())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment