Understanding an otpauth URI

The QR code you scan to set up an authenticator holds an otpauth:// link. Reading its parts explains most setup failures.

Anatomy

otpauth://totp/Example:alice@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example&algorithm=SHA1&digits=6&period=30

  • Type: totp or hotp.
  • Label: Example:alice@example.com, an optional issuer prefix and the account name. It is only shown to you.
  • secret (required): the key in Base32, usually without padding.
  • issuer (recommended): the service name. If the label also has a prefix, the two should match.
  • algorithm, digits, period (optional): default SHA1, 6 and 30.
  • counter (required for HOTP): the starting counter value.

Common faults

  • Characters outside Base32 in the secret (0, 1, 8, 9, or punctuation).
  • Spaces or special characters in the label that were not percent-encoded.
  • Non-default digits, period or algorithm that the chosen app ignores, so it shows codes the service rejects.
  • An hotp link without a counter.

Paste a link into the otpauth validator to check each field, extract one from an image with the QR code reader, or build a link and QR code with the QR code generator.

Handle it like a password

The link contains the secret. Anyone with the link or a screenshot of the QR code can generate your codes, so replace the secret value before sharing an example.

References