--- title: "Testing two-factor authentication with an authenticator app" slug: "testing-totp-2fa" updated: 2025-11-05T06:02:07Z published: 2025-11-05T06:02:07Z canonical: "helpcenter.autify.com/testing-totp-2fa" --- > ## Documentation Index > Fetch the complete documentation index at: https://helpcenter.autify.com/llms.txt > Use this file to discover all available pages before exploring further. # Testing two-factor authentication with an authenticator app This page explains how to test Time-Based One-Time Passwords (TOTP) for two-factor authentication (2FA). In Autify Nexus, you can generate a TOTP using the Dynamic Value Step. Let's look at the steps for setting up 2FA and creating a Scenario, using GitHub as an example. ## Preparation before creating a Scenario #### 1. Obtain the secret key Obtain the secret key for generating TOTPs from your application under test. The secret key is often displayed as a QR code on the 2FA setup screen, but you must retrieve the text string. For example, on GitHub, the "setup key" text shown below links to the secret key. ![](https://cdn.document360.io/c040854c-2c75-49d0-98e1-43f462e8657e/Images/Documentation/image(156).png?sv=2026-02-06&spr=https&st=2026-10-27T19%3A42%3A01Z&se=2026-10-27T20%3A42%3A01Z&sr=c&sp=r&sig=9bJu0%2Fjyi8YN0kRM4A8I7VEjLav7hr0EEjFv%2Fm4R8Xo%3D) #### 2. Set up 2FA with an authenticator app in the target application If you are setting up 2FA in the target application with an authenticator app for the first time, you must complete the setup process first. You can use any authenticator app, or follow the setup steps below using an Autify Nexus Scenario. 1. In any Scenario, add a Dynamic Value Step by navigating to **Insert step > Dynamic Value Step**. ![](https://cdn.document360.io/c040854c-2c75-49d0-98e1-43f462e8657e/Images/Documentation/image(157).png?sv=2026-02-06&spr=https&st=2026-10-27T19%3A42%3A01Z&se=2026-10-27T20%3A42%3A01Z&sr=c&sp=r&sig=9bJu0%2Fjyi8YN0kRM4A8I7VEjLav7hr0EEjFv%2Fm4R8Xo%3D) 2. Edit the added Dynamic Value Step with the following details: - Select **Two-Factor Authentication Code (TOTP)** for the **Dynamic Value Type** field. - Enter the secret key you obtained in the **Secret** field. ![](https://cdn.document360.io/c040854c-2c75-49d0-98e1-43f462e8657e/Images/Documentation/image(158).png?sv=2026-02-06&spr=https&st=2026-10-27T19%3A42%3A01Z&se=2026-10-27T20%3A42%3A01Z&sr=c&sp=r&sig=9bJu0%2Fjyi8YN0kRM4A8I7VEjLav7hr0EEjFv%2Fm4R8Xo%3D) 3. After that step, add a JavaScript Step (**Insert step > JavaScript Step**) and create a step that outputs the TOTP generated in step 2 to the console. ![](https://cdn.document360.io/c040854c-2c75-49d0-98e1-43f462e8657e/Images/Documentation/image(159).png?sv=2026-02-06&spr=https&st=2026-10-27T19%3A42%3A01Z&se=2026-10-27T20%3A42%3A01Z&sr=c&sp=r&sig=9bJu0%2Fjyi8YN0kRM4A8I7VEjLav7hr0EEjFv%2Fm4R8Xo%3D) 4. Save and run the Scenario. From the test result screen, copy the authentication code output to the console. ![](https://cdn.document360.io/c040854c-2c75-49d0-98e1-43f462e8657e/Images/Documentation/image(163).png?sv=2026-02-06&spr=https&st=2026-10-27T19%3A42%3A01Z&se=2026-10-27T20%3A42%3A01Z&sr=c&sp=r&sig=9bJu0%2Fjyi8YN0kRM4A8I7VEjLav7hr0EEjFv%2Fm4R8Xo%3D) 5. Enter the copied code into your target application to complete the setup. ![](https://cdn.document360.io/c040854c-2c75-49d0-98e1-43f462e8657e/Images/Documentation/image(160).png?sv=2026-02-06&spr=https&st=2026-10-27T19%3A42%3A01Z&se=2026-10-27T20%3A42%3A01Z&sr=c&sp=r&sig=9bJu0%2Fjyi8YN0kRM4A8I7VEjLav7hr0EEjFv%2Fm4R8Xo%3D) ## Creating the Scenario Once you have completed the 2FA setup with an authenticator app, you can create the actual test Scenario. 1. Record the steps in your target application as usual, up to the point just before authentication. Enter any temporary authentication code into the TOTP input field and save the Scenario. ![](https://cdn.document360.io/c040854c-2c75-49d0-98e1-43f462e8657e/Images/Documentation/image(161).png?sv=2026-02-06&spr=https&st=2026-10-27T19%3A42%3A01Z&se=2026-10-27T20%3A42%3A01Z&sr=c&sp=r&sig=9bJu0%2Fjyi8YN0kRM4A8I7VEjLav7hr0EEjFv%2Fm4R8Xo%3D) 2. Before the step where you entered the authentication code, add a Dynamic Value Step and edit it as follows: - Select **Two-Factor Authentication Code (TOTP)** for the **Dynamic Value Type** field. - Enter the secret key that you previously obtained in the **Secret** field. ![](https://cdn.document360.io/c040854c-2c75-49d0-98e1-43f462e8657e/Images/Documentation/image(158).png?sv=2026-02-06&spr=https&st=2026-10-27T19%3A42%3A01Z&se=2026-10-27T20%3A42%3A01Z&sr=c&sp=r&sig=9bJu0%2Fjyi8YN0kRM4A8I7VEjLav7hr0EEjFv%2Fm4R8Xo%3D) 3. In the step where you enter the authentication code, select **Other step's output** for the **Text** field. For the value, select the Dynamic Value Step you just added, and then save the Scenario. ![](https://cdn.document360.io/c040854c-2c75-49d0-98e1-43f462e8657e/Images/Documentation/image(162).png?sv=2026-02-06&spr=https&st=2026-10-27T19%3A42%3A01Z&se=2026-10-27T20%3A42%3A01Z&sr=c&sp=r&sig=9bJu0%2Fjyi8YN0kRM4A8I7VEjLav7hr0EEjFv%2Fm4R8Xo%3D) Following these steps, you have successfully created a scenario that obtains and inputs a dynamically generated TOTP each time the test is run. To confirm that 2FA works as expected, you should run the created scenario.