Generate authenticator app provisioning URI
A while ago I published a snippet to generate an OTP auth token from the command line, but I recently got a new phone and had to re-add all my secret keys to a different authenticator app. As I keep all the secret keys backed up I made another script to generate the URI with the correct format, see below.
Don't forget to pip install pyotp
.
I pipe the resulting link into the qr
tool (pip install qrcode
) and scan that with my phone.
#!/usr/bin/env python
import argparse
from pyotp import totp
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate OTP QR url")
parser.add_argument("secret", type=str)
parser.add_argument("issuer", type=str)
parser.add_argument("name", type=str, help="e.g. login name")
args = parser.parse_args()
print(
totp.TOTP(args.secret).provisioning_uri(name=args.name, issuer_name=args.issuer)
)
0 comments
Reply