1001Ferramentas
🔑 Security

TOTP otpauth URI Builder

Builds an otpauth://totp/ URI with issuer, account, base32 secret, digits and period for QR code apps.

Getting the otpauth provisioning URI right

You finished the TOTP work on the server, generated the base32 secret, and now you have to hand it to the user's app. Authenticator apps do not accept a bare secret: they expect a string shaped like otpauth://totp/, with an account label and parameters in the query. Forget the issuer or leave the email unescaped and the app either imports the account under the wrong name or refuses it without saying why.

The label is built as issuer:account, with each half percent-encoded on its own, and the issuer shows up a second time as a query parameter. That repetition is deliberate: older clients read the label prefix, newer ones read the parameter, and Google's key URI format recommends sending both. The secret is only checked against the base32 alphabet (A-Z, 2-7 and =), with spaces stripped and everything upper-cased. No length or checksum validation happens.

The page hands back the URI text, it does not draw a QR code, so copy the string into a QR generator when you build the enrollment screen. First make sure the secret matches exactly what your server stored, and replace the sample value JBSWY3DPEHPK3PXP, which is public and appears in every tutorial. The script makes no network calls at all: the URI is assembled in your browser and the secret never leaves it.

Frequently asked questions

Should the issuer appear in both the label and the query?
Yes, and that is what the builder emits. Old clients parse the label prefix, current ones read the issuer parameter. Keeping them identical prevents a duplicated entry in the user's app.
Can I set SHA256 or eight-digit codes?
The URI carries those fields and the selectors expose them, but many apps quietly ignore algorithm, digits and period and assume SHA1, six digits, thirty seconds. Test against the app your users have before leaving the defaults.
Does it render the QR code?
No. It outputs the otpauth:// text, which you then feed to any QR generator. The URI is the actual data; the QR is just a delivery format.

Related Tools