> ## Documentation Index
> Fetch the complete documentation index at: https://docs.authsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authenticator app (TOTP)

> Implement authenticator app verification in your mobile apps using the Authsignal SDKs for iOS, Android, React Native, and Flutter.

<Info>
  All authenticator app SDK methods require you to [initiate an action
  first](/sdks/client/mobile/actions). Check out our [guide on TOTP
  authentication](/authentication-methods/totp) for more details.
</Info>

### Enroll TOTP

Start enrollment for a new TOTP authenticator by generating a QR code to display to the user.

<CodeGroup>
  ```swift iOS theme={null}
  let response await authsignal.totp.enroll()

  if let data = response.data {
      let uri = data.uri // Convert to QR code
      let secret = data.secret // Can be entered manually
  }
  ```

  ```kotlin Android theme={null}
  val response = authsignal.totp.enroll()

  response.data.let {
      val uri = it.uri // Convert to QR code
      val secret = it.secret // Can be entered manually
  }
  ```

  ```ts React Native theme={null}
  const response = await authsignal.totp.enroll();

  if (response.data) {
    const uri = response.data.uri; // Convert to QR code
    const secret = response.data.secret; // Can be entered manually
  }
  ```

  ```dart Flutter theme={null}
  final response = await authsignal.totp.enroll();

  if (response.data != null) {
      final uri = response.data.uri; // Convert to QR code
      final secret = response.data.secret; // Can be entered manually
  }
  ```
</CodeGroup>

#### Response

<ResponseField name="response" type="AuthsignalResponse<EnrollTotpResponse>">
  <Expandable title="properties">
    <ResponseField name="error" type="string">
      An unstructured error description present if the SDK call encountered an error.
    </ResponseField>
  </Expandable>

  <ResponseField name="data" type="EnrollTotpResponse">
    <Expandable title="properties">
      <ResponseField name="uri" type="string" required>
        A TOTP URI which can be converted into a QR code and presented to the user to scan with
        their authenticator app.
      </ResponseField>

      <ResponseField name="secret" type="string" required>
        The raw TOTP secret which can be presented to the user as a fallback option if they wish to
        enter a code manually instead of scanning a QR code.
      </ResponseField>
    </Expandable>
  </ResponseField>
</ResponseField>

### Verify TOTP

Finish enrolling or re-authenticating a TOTP authenticator by verifying the code submitted by the user.

<CodeGroup>
  ```swift iOS theme={null}
  await authsignal.totp.verify(code: "123456")
  ```

  ```kotlin Android theme={null}
   authsignal.totp.verify(code = "123456")
  ```

  ```ts React Native theme={null}
  await authsignal.totp.verify({ code: "123456" });
  ```

  ```dart Flutter theme={null}
  await authsignal.totp.verify("123456");
  ```
</CodeGroup>

#### Parameters

<ResponseField name="code" type="string">
  The OTP code inputted by the user.
</ResponseField>

#### Response

<ResponseField name="response" type="AuthsignalResponse<VerifyResponse>">
  <Expandable title="properties">
    <ResponseField name="error" type="string">
      An unstructured error description present if the SDK call encountered an error.
    </ResponseField>
  </Expandable>

  <ResponseField name="data" type="VerifyResponse">
    <Expandable title="properties">
      <ResponseField name="isVerified" type="boolean" required>
        True if the verification was successful.
      </ResponseField>

      <ResponseField name="token" type="string">
        A token which can be used for [server-side
        validation](/sdks/server/challenges#validate-challenge).
      </ResponseField>

      <ResponseField name="failureReason" type="string">
        A structured code present if the verification failed due to user error. Possible values are:
        `CODE_INVALID_OR_EXPIRED` or `MAX_ATTEMPTS_EXCEEDED`.
      </ResponseField>
    </Expandable>
  </ResponseField>
</ResponseField>
