square-napkin-92357
05/26/2025, 9:50 AMbrief-egg-61061
05/26/2025, 9:50 AMbrief-egg-61061
05/26/2025, 9:50 AM/self-service/login
endpoint (or the equivalent endpoint for your deployment): json { "method": "totp", "totp_code": "<the code from your authenticator app>", "csrf_token": "<csrf token if required>" }
- method
should be set to "totp"
. - totp_code
is the 6-digit code generated by your TOTP app (e.g., Google Authenticator). - csrf_token
is required for browser flows. Example request body (API reference): json { "method": "totp", "totp_code": "123456", "csrf_token": "your-csrf-token" }
[Ory API Reference – updateLoginFlow](https://www.ory.sh/docs/reference/api) 3. Successful Login: If the TOTP code is valid, the login flow will complete and you will be authenticated. Note: - TOTP must be enabled and configured for the user account before you can use it for login. Users typically pair their account with a TOTP app in the account settings before using TOTP for login. - If you need to enable TOTP in your Ory Kratos configuration, set the following in your config: yaml selfservice: methods: totp: config: issuer: <http://ExampleIssuer.com|ExampleIssuer.com> enabled: true
[TOTP Configuration Guide](https://www.ory.sh/docs/kratos/mfa/totp) For more details on enabling and configuring TOTP, see the [Ory Kratos TOTP documentation](https://www.ory.sh/docs/kratos/mfa/totp).square-napkin-92357
05/26/2025, 9:52 AMTOTP must be enabled and configured for the user account before you can use it for login. Users typically pair their account with a TOTP app in the account settings before using TOTP for login.
brief-egg-61061
05/26/2025, 9:52 AMbrief-egg-61061
05/26/2025, 9:53 AMyaml selfservice: methods: totp: config: issuer: <http://ExampleIssuer.com|ExampleIssuer.com> enabled: true
Then update your project configuration using the CLI as described in the docs [Docs > Kratos > Mfa > Time-based one-time passwords (TOTP)](https://www.ory.sh/docs/kratos/mfa/totp). 2. User Pairs Their Account with a TOTP App - After TOTP is enabled for the project, each user must pair their account with a TOTP app (like Google Authenticator or FreeOTP). - Users do this by signing in and navigating to the Authenticator App section of the Account Settings page in the Ory Account Experience. - There, they will be shown a QR code or a TOTP URL to scan or enter into their authenticator app. This step securely shares the secret needed to generate TOTP codes. > In the Ory Account Experience, users are not automatically prompted to enable TOTP for their accounts. To enable TOTP, users must sign in to their accounts and go to the Authenticator App section of the Account Settings page [Docs > Kratos > Mfa > Time-based one-time passwords (TOTP)](https://www.ory.sh/docs/kratos/mfa/totp). 3. TOTP Credential Storage - Once paired, Ory Kratos stores the TOTP secret in the user's identity credentials. The secret is used to verify the codes generated by the user's authenticator app [Identity credentials](https://www.ory.sh/docs/kratos/mfa/totp#identity-credentials). After these steps, the user can log in using TOTP as a second factor. If you need to customize the identity schema for TOTP (e.g., to display a specific trait in the authenticator app), see the [custom identity schema section](https://www.ory.sh/docs/kratos/mfa/totp#custom-identity-schema).