Whenever I try to set up MFA using TOTP, I get a 4...
# ory-network
f
Whenever I try to set up MFA using TOTP, I get a 400 error with no message about what could be going wrong. This is for the initial set up to pair an authenticator app. Here is the code where I'm submitting the totp code:
Copy code
await ory.updateSettingsFlow({
        flow: flow.id,
        updateSettingsFlowBody: {
          csrf_token: <redacted>,
          method: 'totp',
          totp_code: totpCode
        }
      });
And here is
error.response.data
Copy code
{
  "id": "<redacted>",
  "type": "browser",
  "expires_at": "2023-07-20T22:02:34.745206Z",
  "issued_at": "2023-07-20T21:02:34.745206Z",
  "request_url": "<http://localhost:4000/self-service/settings/browser>",
  "ui": {
    "action": "<http://localhost:4000/self-service/settings?flow=><redacted>",
    "method": "POST",
    "nodes": [
      {
        "type": "input",
        "group": "default",
        "attributes": {
          "name": "csrf_token",
          "type": "hidden",
          "value": "<redacted>",
          "required": true,
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {}
      },
      {
        "type": "input",
        "group": "profile",
        "attributes": {
          "name": "traits.email",
          "type": "email",
          "value": "<redacted>",
          "required": true,
          "autocomplete": "email",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070002,
            "text": "E-Mail",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "profile",
        "attributes": {
          "name": "traits.phone",
          "type": "text",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070002,
            "text": "Phone",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "profile",
        "attributes": {
          "name": "traits.organizationName",
          "type": "text",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070002,
            "text": "Organization Name",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "profile",
        "attributes": {
          "name": "traits.name",
          "type": "text",
          "value": "<redacted>",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070002,
            "text": "Name",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "profile",
        "attributes": {
          "name": "method",
          "type": "submit",
          "value": "profile",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070003,
            "text": "Save",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "password",
        "attributes": {
          "name": "password",
          "type": "password",
          "required": true,
          "autocomplete": "new-password",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070001,
            "text": "Password",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "password",
        "attributes": {
          "name": "method",
          "type": "submit",
          "value": "password",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070003,
            "text": "Save",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "lookup_secret",
        "attributes": {
          "name": "lookup_secret_regenerate",
          "type": "submit",
          "value": "true",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1050008,
            "text": "Generate new backup recovery codes",
            "type": "info"
          }
        }
      },
      {
        "type": "img",
        "group": "totp",
        "attributes": {
          "src": "<redacted>",
          "id": "totp_qr",
          "width": 256,
          "height": 256,
          "node_type": "img"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1050005,
            "text": "Authenticator app QR code",
            "type": "info"
          }
        }
      },
      {
        "type": "text",
        "group": "totp",
        "attributes": {
          "text": {
            "id": 1050006,
            "text": "DBZVIOY2CHR4WMWRCW4RWENIWNL6ORFE",
            "type": "info",
            "context": {
              "secret": "DBZVIOY2CHR4WMWRCW4RWENIWNL6ORFE"
            }
          },
          "id": "totp_secret_key",
          "node_type": "text"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1050017,
            "text": "This is your authenticator app secret. Use it if you can not scan the QR code.",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "totp",
        "attributes": {
          "name": "totp_code",
          "type": "text",
          "required": true,
          "disabled": false,
          "node_type": "input"
        },
        "messages": [
          {
            "id": 4000008,
            "text": "The provided authentication code is invalid, please try again.",
            "type": "error",
            "context": {}
          }
        ],
        "meta": {
          "label": {
            "id": 1070006,
            "text": "Verify code",
            "type": "info"
          }
        }
      },
      {
        "type": "input",
        "group": "totp",
        "attributes": {
          "name": "method",
          "type": "submit",
          "value": "totp",
          "disabled": false,
          "node_type": "input"
        },
        "messages": [],
        "meta": {
          "label": {
            "id": 1070003,
            "text": "Save",
            "type": "info"
          }
        }
      }
    ]
  },
  "identity": {
    "id": "<redacted>",
    "schema_id": "<redacted>",
    "schema_url": "<http://localhost:4000/schemas/><redacted>",
    "state": "active",
    "state_changed_at": "2023-07-14T18:48:35.523047Z",
    "traits": {
      "email": "<redacted>",
      "name": "<redacted>"
    },
    "verifiable_addresses": [
      {
        "id": "<redacted>",
        "value": "<redacted>",
        "verified": false,
        "via": "email",
        "status": "sent",
        "created_at": "2023-07-14T18:48:35.531685Z",
        "updated_at": "2023-07-14T18:48:35.531685Z"
      }
    ],
    "recovery_addresses": [
      {
        "id": "<redacted>",
        "value": "<redacted>",
        "via": "email",
        "created_at": "2023-07-14T18:48:35.541824Z",
        "updated_at": "2023-07-14T18:48:35.541824Z"
      }
    ],
    "metadata_public": null,
    "created_at": "2023-07-14T18:48:35.527058Z",
    "updated_at": "2023-07-14T18:48:35.527058Z"
  },
  "state": "show_form"
}
p
Hi @full-scientist-38268 The json has a message stating that the TOTP code is incorrect.
Copy code
...      
{
        "type": "input",
        "group": "totp",
        "attributes": {
          "name": "totp_code",
          "type": "text",
          "required": true,
          "disabled": false,
          "node_type": "input"
        },
        "messages": [
          {
            "id": 4000008,
            "text": "The provided authentication code is invalid, please try again.",
            "type": "error",
            "context": {}
          }
        ],
        "meta": {
          "label": {
            "id": 1070006,
            "text": "Verify code",
            "type": "info"
          }
        }
      }
f
Ah I completely missed that! Thank you @proud-plumber-24205