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

# Test MFA with an authenticator app

> Generate a time-based OTP code in your flow to complete multi-factor authentication.

<Info>
  Store your authenticator app's OTP URI as a QA Wolf environment variable named `OTP_URI` before running this flow.
</Info>

## Examples

**Complete MFA during login**

```typescript theme={null}
import { otp } from "@qawolf/testkit";

const code = otp.fromUri(process.env["OTP_URI"]!);
await page.getByLabel("Verification code").fill(code);
```

## When to use

* Your app requires a time-based one-time password (TOTP) to complete login
* Your app prompts for an MFA code after username and password are accepted
* Your flow needs to authenticate as a user who has MFA enabled
* Your test environment enforces MFA and cannot be bypassed for test accounts

## Full example

```typescript theme={null}
import { flow } from "@qawolf/flows/web";
import { otp } from "@qawolf/testkit";

export default flow(
  "Log in with MFA",
  { target: "Web - Chrome", launch: true },
  async ({ page, test }) => {
    await test("log in", async () => {
      await page.goto(process.env["BASE_URL"]!);
      await page.fill('[name="email"]', process.env["EMAIL"]!);
      await page.fill('[name="password"]', process.env["PASSWORD"]!);
      await page.click('[type="submit"]');
    });

    await test("complete MFA", async () => {
      const code = otp.fromUri(process.env["OTP_URI"]!);
      await page.getByLabel("Verification code").fill(code);
      await page.click('[type="submit"]');
    });
  },
);
```
