Factors — TOTP

Factors

This factor operates by generating a One-Time Password (OTP) on-demand through an application which is called an Authenticator App. The application is seeded with a shared secret upon setup, allowing it to continuously generate a new code every 30 seconds, and our service to validate the code in combination with the exact time. Hence why this factor is also called Time-Based One-Time Password (TOTP).

This factor supports all generally-used authenticator apps through the OATH TOTP standard (RFC 6238), for example:

  • Google Authenticator
  • Microsoft Authenticator
  • Authy
  • FreeOTP (open source)
  • Aegis (open source)
  • password managers with TOTP support, such as 1Password or Bitwarden

Configuration

Next to the general configuration options, TOTP factors have following configuration options:

  • Issuer (config.issuer: string) - The name shown for the entry in the authenticator app, e.g. your company or application name. Defaults to Quasr.
  • Require Validation (config.require_validation_for_enablement: boolean) - Whether a new enrollment must first be validated with a code before it's enabled. Defaults to true.
  • Expires In (config.expires_in: string) - How long users have to validate a new enrollment, defaults to 10m.

Following settings are fixed:

  • codes have 6 digits, are generated with SHA-1 and change every 30 seconds (config.window: 30s), which are the defaults of all common authenticator apps
  • the factor is never unique, as the code doesn't identify the user; users first identify themselves with another factor, e.g. a username or email address
  • an enrollment is locked after 5 consecutive failed attempts and unlocks after 5 minutes, see Locking

Enrollment

Users enroll in following steps, in the Login UI during signup or later on in the Account UI:

  1. Quasr generates a random secret and returns it as an otpauth:// URI, which the UI shows as a QR code together with the setup key (the secret itself).
  2. The user scans the QR code with their authenticator app, or enters the setup key manually. The entry is labelled with the issuer and the user's account ID.
  3. The user enters the code shown by the app, which validates the enrollment and enables it.

Enrolling at signup

  1. 1An otpauth:// URI with the issuer (Example Corp) and the secret, for the authenticator app to scan
  2. 2The same secret, to enter manually; both are only shown once

Logging in with the code from the app

An enrollment that isn't validated before it expires (see Expires In) is deleted, and the user has to start over.

Admins can also create a TOTP enrollment for an internal user, e.g. to hand over a pre-configured device, in which case the Admin UI shows the QR code and setup key once. See Users — Enrollments.

Login

At login the user enters the code currently shown by their authenticator app for the enrollment. Following applies:

  • only the code of the current 30-second period is accepted, so the time of the user's device must be accurate (most devices synchronize their time automatically)
  • each code can only be used once, so a code that was intercepted can't be replayed
  • failed attempts count towards locking the enrollment, see Locking

Lost Device

The secret of an enrollment can't be changed. If a user loses or replaces their device, disable or delete the enrollment and let the user enroll again with their new device. See Users — Enrollments.

TOTP enrollments can't be found with searchEnrollments, as their secret isn't a value that identifies the user.

API

Below are the steps for the factors endpoint of the Authentication API. See Factors — Authentication API for how requests, responses, sessions and the Management API work in general.

Signup

1. With the signup session token, send the ID of the TOTP factor without input. This creates a pending enrollment and returns the otpauth:// URI (initialization_url) to show as QR code, and the setup key (secret):

POST /factors HTTP/1.1Host: {tenant_id}.api.quasr.ioAuthorization: Bearer {signup_session_token}Content-Type: application/json [    {        "id": "{totp_factor_id}"    }]
{    "result": "PENDING",    "feedback": {        "cause": "ENROLLMENT_PENDING",        "enrollment_id": "{enrollment_id}",        "expires_at": "2026-11-06T10:10:00.000Z",        "initialization_url": "otpauth://totp/{issuer}:{account_id}?secret={secret}&issuer={issuer}",        "secret": "{secret}",        "regex": "^[0-9]{6}$"    }}

2. Send the code shown by the authenticator app with the ID of the enrollment, which completes the enrollment:

POST /factors HTTP/1.1Host: {tenant_id}.api.quasr.ioAuthorization: Bearer {signup_session_token}Content-Type: application/json [    {        "id": "{enrollment_id}",        "input": "123456"    }]
Login

After the user is identified with another factor, send the code with the ID of the TOTP enrollment and the session token:

POST /factors HTTP/1.1Host: {tenant_id}.api.quasr.ioAuthorization: Bearer {session_token}Content-Type: application/json [    {        "id": "{totp_enrollment_id}",        "input": "123456"    }]
{    "result": "SUCCESS",    "feedback": {        "cause": "",        "enrollment_id": "{totp_enrollment_id}"    },    "account_id": "{account_id}",    "session_token": "{session_token}",    "session_score": 4,    "session_exp": 1767225600}
Management API

A signed-in user adds an authenticator app with createEnrollment, which returns the otpauth:// URI in output, and completes it with updateEnrollment and a code:

mutation {    createEnrollment(input: {        account: "{account_id}",        factor: "{totp_factor_id}",        subtype: "totp",        status: ENABLED    }) {        id        status        output    }} mutation {    updateEnrollment(input: {        id: "{enrollment_id}",        input: "123456"    }) {        id        status    }}
2026.11.22 | © Copyright 2026 Quasr BV