famous-jackal-2829
06/07/2025, 11:52 AMbrief-egg-61061
06/07/2025, 11:52 AMbrief-egg-61061
06/07/2025, 11:52 AMyaml selfservice: methods: totp: config: issuer: <http://ExampleIssuer.com|ExampleIssuer.com> enabled: true
[How to enable TOTP](https://www.ory.sh/docs/kratos/mfa/totp#enabling-totp-authentication) 2. Let users pair their TOTP app Users must go to their account settings and pair their account with a TOTP app (like Google Authenticator). This is typically done through the Ory Account Experience UI, but you can also build your own UI using the SDK and API. 3. Update the settings flow to add TOTP In your Go application, use the Ory Go SDK to update the settings flow and add TOTP for the user. Here’s a code snippet for interacting with the Admin API (for reference): go import ( "context" ory "<http://github.com/ory/client-go|github.com/ory/client-go>" ) client := ory.NewAPIClient(ory.NewConfiguration()) // Example: Update settings flow with TOTP flowId := "your-settings-flow-id" totpCode := "123456" // The code from the user's authenticator app body := map[string]interface{}{ "method": "totp", "totp_code": totpCode, } resp, _, err := client.FrontendApi.UpdateSettingsFlow(context.Background(), flowId).Body(body).Execute() if err != nil { // Handle error } // resp contains the updated flow
The request body must include "method": "totp"
and the TOTP code from the user. You may also need to provide a CSRF token if using browser flows. [API reference for updating settings flow with TOTP](https://www.ory.sh/docs/kratos/reference/api#updateSettingsFlow) 4. Login with TOTP When logging in, after the user provides their primary credentials, prompt for the TOTP code and submit it as part of the login flow: go body := map[string]interface{}{ "method": "totp", "totp_code": totpCode, } resp, _, err := client.FrontendApi.UpdateLoginFlow(context.Background(), flowId).Body(body).Execute()
[API reference for updating login flow with TOTP](https://www.ory.sh/docs/kratos/reference/api#updateLoginFlow) Note: - The Go SDK uses the OpenAPI-generated client, so you interact with flows by creating or updating them and passing the required fields. - Users must first pair their TOTP app before they can use TOTP for login. For more details and configuration options, see the official documentation: [Ory Kratos TOTP MFA](https://www.ory.sh/docs/kratos/mfa/totp) [Ory Go SDK reference](https://www.ory.sh/docs/kratos/sdk/go)famous-jackal-2829
06/07/2025, 11:55 AMbrief-egg-61061
06/07/2025, 11:55 AMbrief-egg-61061
06/07/2025, 11:55 AMjson { "type": "text", "group": "totp", "attributes": { "text": { "id": 1050006, "text": "GLAS5YHAJ6V5LT3N7AU2R4AWU6SYOCHS", "type": "info", "context": { "secret": "GLAS5YHAJ6V5LT3N7AU2R4AWU6SYOCHS" } }, "id": "totp_secret_key", "node_type": "text" }, "messages": [], "meta": { "label": { "id": 1050006, "text": "This is your authenticator app secret. Use it if you can not scan the QR code.", "type": "info" } } }
If a QR code is available, it will also be included in the nodes, typically as a base64-encoded image. You can render this in your UI by extracting the image data and displaying it in an <img>
tag. Summary of steps: 1. Start a settings flow for the user. 2. Parse the response for TOTP-related nodes. 3. Display the secret and/or QR code in your UI. This approach allows you to show the TOTP setup information separately and style it as needed in your application UI, independent of the default Ory Account Experience interface. For more details and examples, see the documentation on [UI nodes and TOTP](https://www.ory.sh/docs/kratos/concepts/ui-user-interface#ui-text-nodes) and [TOTP setup](https://www.ory.sh/docs/kratos/mfa/totp#identity-credentials) in Ory Kratos.famous-jackal-2829
06/07/2025, 12:12 PMbrief-egg-61061
06/07/2025, 12:13 PMbrief-egg-61061
06/07/2025, 12:13 PMError when calling `FrontendApi.GetSettingsFlow`: Get "/admin/self-service/settings/flows?id=...": stopped after 10 redirects Full HTTP response: ... 307 Temporary Redirect ... Location:[/admin/self-service/settings/flows?id=...]
indicates that your request to the GetSettingsFlow endpoint is being redirected repeatedly, resulting in a redirect loop. Possible causes and solutions based on Ory documentation: 1. Wrong Endpoint (Admin vs. Public API): The /admin/self-service/settings/flows
endpoint is for the Admin API, but the settings flow for end-users should be handled via the Public API (typically /self-service/settings/flows
). Using the wrong endpoint can cause redirect issues, especially if the service is behind a reverse proxy or load balancer. 2. Missing or Incorrect Cookies/Session: The settings flow for browser clients relies on session cookies. If you do not provide the correct session cookie or token, Ory will redirect you to the login page or back to the flow, causing a loop. Make sure you are passing the session cookie or token as required by the API. [See: User and profile settings for server-side browser clients](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#user-and-profile-settings-for-server-side-browser-clients) 3. Incorrect UI URL Configuration: If the selfservice.flows.settings.ui_url
is not set correctly, Ory may not know where to redirect the user, which can also result in redirect loops. [See: Settings UI configuration](https://www.ory.sh/docs/kratos/fallback/settings) 4. Redirect Configuration Issues: If your redirect URLs are not properly configured or whitelisted, Ory may not be able to complete the flow and will keep redirecting. [See: Browser redirects and flow completion](https://www.ory.sh/docs/kratos/concepts/browser-redirect-flow-completion) What you should check: - Make sure you are using the correct (public) endpoint for the settings flow: /self-service/settings/flows
. - Ensure you are passing the required session cookie or token with your request. - Verify your ui_url
and allowed return URLs are set correctly in your Ory configuration. - If you are running behind a reverse proxy, ensure headers and paths are forwarded correctly. If you continue to see this issue after checking the above, please provide more details about your configuration and how you are making the request. --- References: - [User and profile settings for server-side browser clients](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#user-and-profile-settings-for-server-side-browser-clients) - [Settings UI configuration](https://www.ory.sh/docs/kratos/fallback/settings) - [Browser redirects and flow completion](https://www.ory.sh/docs/kratos/concepts/browser-redirect-flow-completion)famous-jackal-2829
06/07/2025, 12:15 PMbrief-egg-61061
06/07/2025, 12:15 PMbrief-egg-61061
06/07/2025, 12:16 PM/self-service/settings/flows
). The Admin API is not designed for browser/self-service flows and will result in redirect loops or errors, as you are experiencing. ### Details from the Knowledge Sources - The [GetSettingsFlow](https://www.ory.sh/docs/kratos/reference/api#getSettingsFlow) endpoint is meant to be accessed via the public API, not the admin API. When using the public API, you must ensure that either the Ory Kratos Session Cookie or the Ory Kratos Session Token are set. - The documentation explicitly states: > You can access this endpoint without credentials when using Ory Kratos' Admin API. However, the self-service flows (like settings, login, registration) are designed for end-user interaction and should be handled via the public endpoints, not the admin endpoints. [See: Get Settings Flow](https://www.ory.sh/docs/kratos/reference/api#getSettingsFlow) - The redirect loop (stopped after 10 redirects
) is a common symptom when the wrong endpoint is used or when required session information (cookie or token) is missing. [See: User and profile settings for server-side browser clients](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#user-and-profile-settings-for-server-side-browser-clients) ### How to Fix 1. Use the Public API Endpoint for Self-Service Flows Change your configuration to use the public endpoint, for example: go configuration.Servers = []kratos.ServerConfiguration{ { URL: "<https://kratos.qaap.io>", // Public API, not /admin }, }
2. Pass Session Cookie or Token When calling self-service flows, you must provide the session cookie or token. If you are not authenticated, you will be redirected to the login flow, causing a loop. 3. Admin API is for Administrative Actions Creating, getting, and deleting identities should use the Admin API (/admin
), but self-service flows (settings, login, registration) should use the public API. ### Example Correction go configuration := kratos.NewConfiguration() configuration.Servers = []kratos.ServerConfiguration{ { URL: "<https://kratos.qaap.io>", // Use public endpoint for self-service flows }, } apiClient := kratos.NewAPIClient(configuration) // For GetSettingsFlow, ensure you pass the session cookie or token if required settings, r, err := apiClient.FrontendAPI.GetSettingsFlow(context.Background()).Id(flow_id).Execute()
Summary: - Use the public API endpoint for self-service flows. - Use the admin API endpoint only for administrative actions (like creating identities). - Always provide the required session information for self-service flows. For more details, see the official documentation on [Get Settings Flow](https://www.ory.sh/docs/kratos/reference/api#getSettingsFlow) and [User and profile settings for server-side browser clients](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#user-and-profile-settings-for-server-side-browser-clients).