Skip to content

otpauth URI builder for authenticator apps

Build the otpauth:// URI that authenticator apps read from a QR code, with the issuer, account, secret, digits and period.

Runs in your browser. Nothing you paste is sent to us.

Details

The service name the app shows, such as your realm’s display name.

Usually the username. Sample values are filled in.

The RFC 6238 test secret is filled in.

URI

otpauth URI
otpauth://totp/Example%20Corp:alice?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Example%20Corp&algorithm=SHA1&digits=6&period=30
Type
TOTP
Label
Example Corp:alice
Secret size
160 bits
The URI holds the secret
Anyone with this URI, or a QR code of it, can make the codes. Share it only with the person enrolling.

How to use it

  1. Choose TOTP or HOTP.
  2. Enter the issuer and the account name.
  3. Paste the Base32 secret or make a new random one.
  4. Set the algorithm, digits and period, then copy the URI.

What to know

The URI looks like otpauth://totp/Issuer:account?secret=…&issuer=Issuer. An authenticator app reads it, usually from a QR code, and stores the secret.

Many apps only support SHA1, 6 digits and 30 seconds and ignore other values. Keep to those unless you have tested the apps your users have.

Keycloak builds this URI and its QR code itself when a user sets up an authenticator. This tool helps test apps, migrate secrets or check what a setup screen encodes.

What an otpauth URI is

When you scan a QR code to add an account to an authenticator app, the QR code contains a link that starts with otpauth://. The link tells the app everything it needs: the type of one-time password, the account name, the issuer, the shared secret and the settings for computing codes.

The format began as Google Authenticator’s Key Uri Format and became the common way to enroll any TOTP or HOTP app. It is a convention rather than an IETF standard, which is why apps differ in which parameters they honor.

This tool builds the URI from its parts, so you can check what a QR code should contain, test apps, or prepare test enrollments.

Anatomy of the URI

A TOTP URI with sample values (the secret is the RFC 6238 test secret)
otpauth://totp/Example%20Corp:alice?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Example%20Corp&algorithm=SHA1&digits=6&period=30
PartExampleMeaning
Typetotp or hotpTime-based or counter-based codes
LabelExample%20Corp:aliceIssuer and account, separated by a colon, each percent-encoded
secretBase32, no paddingThe shared secret. Required.
issuerExample%20CorpThe service name. Should match the label’s issuer prefix.
algorithmSHA1, SHA256, SHA512The HMAC hash. Defaults to SHA1.
digits6 or 8Code length. Defaults to 6.
period30TOTP step in seconds. Defaults to 30.
counter0HOTP starting counter. Required for HOTP.

Issuer in two places

The issuer can appear as a prefix in the label and as the issuer parameter. Older apps read only the prefix; newer ones prefer the parameter. Putting the same value in both is the safest way to get the right name shown in every app.

Encoding the label

Spaces and special characters in the issuer or account must be percent-encoded, so Example Corp becomes Example%20Corp. The colon between issuer and account is the separator, so the issuer itself must not contain a colon. This tool refuses one.

App support for the parameters

Because the format is a convention, apps implement it differently. Many apps ignore algorithm, digits and period and always use SHA1, six digits and 30 seconds. When an app ignores a setting the server relies on, its codes are simply wrong, and the user cannot tell why.

The practical rule: use SHA1, six digits and 30 seconds unless you have tested every app your users might choose with something else. These are also Keycloak’s defaults.

What this tool does and does not do

  • It builds otpauth://totp/... or otpauth://hotp/... URIs with the label, secret, issuer, algorithm, digits and period or counter.
  • It accepts the secret in Base32 with any case, spaces or dashes, and writes it in canonical uppercase Base32 without padding.
  • It can make a new random 160-bit secret.
  • It checks the secret is valid Base32, that the issuer has no colon and that the counter and period are numbers.
  • It does not draw a QR code. Use a QR generator you trust that runs locally, since the URI contains the secret.
  • It does not send the URI or secret anywhere.

How to build a URI

  1. Choose TOTP for authenticator apps, or HOTP if your system uses counters.
  2. Enter the issuer, the name users should see in their app.
  3. Enter the account, usually the username or email.
  4. Paste the Base32 secret, or press New random secret for a test enrollment.
  5. Keep SHA1, 6 digits and 30 seconds unless you know the apps support more.
  6. Copy the URI. Turn it into a QR code locally, or open it on a phone with an authenticator installed.

Where this helps with Keycloak

Keycloak builds this URI and its QR code itself, so day to day you never need to. The tool helps around the edges.

Understanding the enrollment screen

During the Configure OTP required action, Keycloak shows a QR code and offers to show the secret for manual entry. The QR code holds an otpauth URI with the realm’s OTP policy settings. Building the same URI here shows what users’ apps receive.

Testing a new OTP policy

Before changing the realm’s OTP policy to SHA256 or eight digits, enroll test accounts with URIs built here in each app your users have, and compare the codes with the TOTP generator. If an app shows a different code, it ignores the setting.

Migrating users with existing secrets

When moving users from another system, you may have their OTP secrets. If you import them into Keycloak with the same settings, users keep their existing app entries. If you cannot, users re-enroll; a clear message beforehand saves support work.

Naming the issuer well

Users often have many entries in their authenticator. An issuer that names the service people know, not an internal system name, helps them pick the right code. When you migrate or build enrollments yourself, choose it with care, because changing it later means users re-enroll or live with the old name.

Common mistakes

  • Putting a colon or unencoded spaces in the issuer, which splits the label in the wrong place.
  • Giving the issuer only in the label or only as a parameter, so some apps show it and others do not.
  • Including Base32 padding or lowercase letters, which a few apps reject.
  • Using SHA256 or eight digits with apps that silently ignore them.
  • Generating QR codes with an online service that receives the URI, and with it the secret.
  • Reusing the same secret for several users or several devices.

Security notes

An otpauth URI is the secret in a convenient form. Anyone who sees it, or a photo of its QR code, can generate valid codes for that account. Show enrollment QR codes only to the user enrolling, only once, and never send them by email or chat.

Use a fresh random secret of at least 160 bits per enrollment. RFC 4226 requires at least 128 bits and recommends 160.

If a URI or QR code may have been exposed, delete the OTP credential and have the user enroll again with a new secret.

Best practices

  • Keep TOTP with SHA1, six digits and 30 seconds for compatibility.
  • Set the issuer both as the label prefix and as the parameter.
  • Make QR codes locally and show them once.
  • Confirm enrollment by asking the user for a code before saving the secret, as Keycloak does.
  • Offer recovery codes or a second method so a lost phone is not a lockout.

HOTP URIs and the counter

For HOTP the URI carries counter instead of period. It is the counter value the app should start from. Each time the user asks the app for a code, the app moves its counter forward by one; the server moves its own counter when it accepts a code.

Because pressing the button without signing in moves only the app’s counter, the two drift apart. Servers handle this with a look-ahead window: they try several counters ahead and resynchronize when one matches. Keycloak’s OTP policy has an initial counter and a look-around window for HOTP for this reason.

Most people use TOTP. Choose HOTP only for hardware tokens or systems built around counters.

Making a QR code safely

An otpauth QR code is a picture of the secret. Treat it like a password on screen.

  • Use a QR library or command-line tool that runs on your machine, such as qrencode, rather than a website that receives the text.
  • Show the code only on the enrolling user’s screen, and remove it once enrollment is confirmed.
  • Do not save QR images to shared drives, tickets or chat.
  • For test enrollments, use test secrets that protect nothing.
Questions

Frequently asked questions

What is the otpauth URI format?

It is otpauth://TYPE/LABEL?PARAMETERS, where TYPE is totp or hotp, LABEL is issuer:account, and the parameters include secret, issuer, algorithm, digits and period or counter. Authenticator apps read it from a QR code.

How do I create a QR code for Google Authenticator?

Build the otpauth URI, then encode it as a QR code with a generator that runs on your own machine. Avoid online QR services, because the URI contains the secret.

Why does my authenticator show the wrong account name?

The app reads the issuer and account from the label and the issuer parameter. Set both, use the same issuer in each, and percent-encode spaces.

Do authenticator apps support SHA256 and 8 digits?

Some do and many do not; those that do not usually ignore the setting without warning. Test each app, or keep SHA1 and six digits.

Should the secret include = padding?

No. The common convention is Base32 without padding, in uppercase. Some apps reject padded secrets.

Is it safe to share an otpauth link?

No. The link contains the secret, so anyone with it can generate the account’s codes. Share it only with the person enrolling, and only once.

Does Keycloak show the otpauth URI?

Keycloak shows the QR code during OTP setup and can show the secret for manual entry. The QR code holds an otpauth URI built from the realm’s OTP policy.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.