> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-en/action-guides/text-and-number/two-factor-authentication.md).

# 2FA code

2FA code is the action of automatically generating a time-based 6-digit two-factor authentication code (similar to the Google Authenticator or Authy app on your phone) from a provided secret key.

This action is extremely important in MMO scenarios, helping to automatically bypass the security verification step when logging into accounts like Facebook, Google, X (Twitter), Discord, Coinlist... without needing to open your phone to manually enter the code.

#### Configuration parameters:

* Secret key: The original secret key (A long alphanumeric string, usually provided when you enable two-factor security on websites).
* Output variable: The name of the variable that stores the generated 6-digit authentication code.

#### Real-world example: Automatically filling in the 2FA code when logging into Facebook

Suppose you have the data of a Facebook account stored in Excel, where the two-factor secret key (Secret key) for this account is: `JBSWY3DPEHPK3PXP`.

When the browser navigates to the Facebook login page, after entering the User/Pass, Facebook will prompt for a 6-digit authentication code to access the account. You configure the automation script as follows:

* Configuration steps:
  * Call the 2FA code action.
  * Secret key: Enter the string `JBSWY3DPEHPK3PXP` (or pass a variable containing this string from the Excel file).
  * Output variable: Name the variable `$twoFACode`.
* Result: The system will use the time-based encryption algorithm to immediately calculate the current 6-digit code (for example: `482915`) and store it in the variable `$twoFACode`. Immediately after this action, you call the Key press command to input the variable `$twoFACode` into the code entry field on Facebook to successfully log in.

<figure><img src="/files/sUwgcvUK72qizD7zbs3A" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-en/action-guides/text-and-number/two-factor-authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
