# 身份验证器码

节点类型 `browser_get2faCode`

## 功能说明

根据配置的身份验证器密钥生成当前时段的验证码。

## 客户端配置界面

![身份验证器码节点的客户端配置界面](/assets/get2fa-code.881db20f1e13f1257ced12091ad41dce4366322b4c9e58bda81c7ebe008fa6d3.0538f3a9.webp)

截图来自 MoreLogin 桌面客户端 V2.73.101 的英文界面。

## 输入字段

以下字段位于 `data.browserUi.inputs`。

| 字段 | 类型或取值 | Schema 必填 | 执行默认值 | 说明与边界 |
|  --- | --- | --- | --- | --- |
| `secret` | `string` | 否 | — | 2FA 密钥 |


## 条件与边界

- secret 是 Base32 密钥；直接填写时只能包含字母、数字和空格，最多 100 个字符（写入时校验，引用变量的值不校验）；运行时先去掉所有非单词字符（空格、-、= 等）；真实生成 6 位 TOTP，不使用 demo 固定验证码。expiresAt 为本周期（30 秒）到期的客户端本地时间 YYYY-MM-DD HH:mm:ss，remainingSeconds 为剩余秒数。
- 校验错误码 `RPA_NODE_INPUT_INVALID`


## 输入引用

| 字段 | 允许的形式 |
|  --- | --- |
| `secret` | `literal`, `template` |


## 输出字段

| 输出字段 | 类型或取值 |
|  --- | --- |
| `code` | `string` |
| `expiresAt` | `string` |
| `remainingSeconds` | `number` |


按契约用 `${nodeId.data.field}` 引用公开字段。

## JSON 示例

可放入流程 `nodes` 数组或其他节点 `blocks` 中的完整节点对象。`totpSecret` 是在 `workflow.variables` 中声明的私密初始化参数。

```json
{
  "id": "totp_code",
  "type": "browser_get2faCode",
  "data": {
    "title": "生成登录验证码",
    "browserAction": "get2faCode",
    "browserUi": {
      "inputs": {
        "secret": "${totpSecret}"
      },
      "exception": {
        "timeout": 30000,
        "policy": "interrupt"
      }
    }
  }
}
```

[返回节点目录](/zh/browser-rpa/nodes)