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

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(, issuer_name=args.issuer))


Start a new thread

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.
DjangoPythonBitcoinTuxDebianHTML5 badgeSaltStackUpset confused bugMoneyHackerUpset confused bugX.OrggitFirefoxWindowMakerBashIs it worth the time?i3 window managerWagtailContainerIrssiNginxSilenceTorWorldInternet securityFontGnuPGThunderbirdJenkins