# TotpMultiFactorGenerator


```
public final class TotpMultiFactorGenerator
```

<br />

*** ** * ** ***

Helper class used to generate a `https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpMultiFactorAssertion`.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpMultiFactorGenerator#FACTOR_ID() = "totp"` |

| ### Public methods |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developers.google.com/android/reference/com/google/android/gms/tasks/Task.html<https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpSecret>` | `https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpMultiFactorGenerator#generateSecret(com.google.firebase.auth.MultiFactorSession)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/auth/MultiFactorSession session)` Creates a TOTP secret as part of enrolling a TOTP (time-based one-time password) second factor. |
| `static @https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpMultiFactorAssertion` | `https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpMultiFactorGenerator#getAssertionForEnrollment(com.google.firebase.auth.TotpSecret,java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpSecret secret, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html otp)` Creates an assertion for completing the enrollment flow. |
| `static @https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpMultiFactorAssertion` | `https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpMultiFactorGenerator#getAssertionForSignIn(java.lang.String,java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html enrollmentId, @https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html otp)` Creates an assertion for the sign-in flow. |

## Constants

### FACTOR_ID

```
public static final String FACTOR_ID = "totp"
```

## Public methods

### generateSecret

```
public static @NonNull Task<TotpSecret> generateSecret(@NonNull MultiFactorSession session)
```

Creates a TOTP secret as part of enrolling a TOTP (time-based one-time password) second factor. This method uses the auth instance corresponding to the user in the `https://firebase.google.com/docs/reference/android/com/google/firebase/auth/MultiFactorSession`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/auth/MultiFactorSession session` | `https://firebase.google.com/docs/reference/android/com/google/firebase/auth/MultiFactorSession`. |

### getAssertionForEnrollment

```
public static @NonNull TotpMultiFactorAssertion getAssertionForEnrollment(@NonNull TotpSecret secret, @NonNull String otp)
```

Creates an assertion for completing the enrollment flow.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpSecret secret` | obtained from the `https://firebase.google.com/docs/reference/android/com/google/firebase/auth/TotpMultiFactorGenerator#generateSecret(com.google.firebase.auth.MultiFactorSession)` step. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html otp` | one-time password obtained from the TOTP App. |

### getAssertionForSignIn

```
public static @NonNull TotpMultiFactorAssertion getAssertionForSignIn(@NonNull String enrollmentId, @NonNull String otp)
```

Creates an assertion for the sign-in flow.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html enrollmentId` | identifies the TOTP second factor being used. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull.html https://developer.android.com/reference/java/lang/String.html otp` | one-time password obtained from the TOTP App. |