rough-airplane-18783
04/22/2025, 9:20 AMbrief-egg-61061
04/22/2025, 9:20 AMbrief-egg-61061
04/22/2025, 9:20 AMrough-airplane-18783
04/25/2025, 12:38 PMbrief-egg-61061
04/25/2025, 12:38 PMbrief-egg-61061
04/25/2025, 12:39 PMrough-airplane-18783
07/16/2025, 7:38 AMbrief-egg-61061
07/16/2025, 7:38 AMbrief-egg-61061
07/16/2025, 7:39 AMGET /self-service/login/api This endpoint is specifically designed for native apps (such as mobile devices, smart TVs, etc.) and should not be used in browser-based applications. It initializes a login flow and returns all the necessary data for rendering the login UI in your native app. On successful login, Ory issues a session token that can be used to authenticate subsequent requests from the app. Example cURL request: bash curl -X GET \ -H "Accept: application/json" \ https://$<http://PROJECT_SLUG.projects.oryapis.com/self-service/login/api|PROJECT_SLUG.projects.oryapis.com/self-service/login/api> Replace $PROJECT_SLUG with your actual Ory project slug or domain. Important notes: - Do not use this endpoint in browser or SPA applications, as it does not provide CSRF protection and is intended only for native environments. - On successful login, you will receive a session token (not a cookie) to use for authenticating further API requests from your app. For more details, see the official documentation: [Create Login Flow for Native Apps](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#create-login-flow) and [API Reference](https://raw.githubusercontent.com/ory/kratos/master/spec/api.json).rough-airplane-18783
07/16/2025, 7:39 AMrough-airplane-18783
07/16/2025, 7:40 AMbrief-egg-61061
07/16/2025, 7:41 AMbrief-egg-61061
07/16/2025, 7:41 AMGET /self-service/login/api This endpoint initializes a login flow for API clients such as mobile devices. After initializing the flow, you will receive a JSON response containing the flow ID and UI nodes, which you use to render the login form in your app. To submit the login credentials, you send a POST request to the action URL provided in the flow response. Example flow: 1. Initialize the login flow: bash curl -X GET \ -H "Accept: application/json" \ https://<your-ory-domain>/self-service/login/api This returns a JSON object with the flow details, including the ui.action URL and form fields to render. 2. Submit the login form: bash curl -X POST \ -H "Content-Type: application/json" \ -d '{"method":"password","identifier":"<mailto:email@example.com|email@example.com>","password":"yourpassword"}' \ "https://<your-ory-domain>/self-service/login?flow=<flow-id>" Replace <your-ory-domain> and <flow-id> with your actual values. Note: - This is for self-service flows, not the Ory Console. - Do not use this endpoint in browser-based apps; it is intended for native/mobile clients only. For more details, see the official documentation on [API flows for native apps](https://www.ory.sh/docs/kratos/self-service#api-flows-native-mobile--desktop-apps-command-line-interfaces-smart-tvs-and-more) and [custom UI integration](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration#create-login-flow).rough-airplane-18783
07/17/2025, 10:59 AMbrief-egg-61061
07/17/2025, 10:59 AMbrief-egg-61061
07/17/2025, 10:59 AMyaml session: cookie: domain: $<http://PROJECT_SLUG.projects.oryapis.com|PROJECT_SLUG.projects.oryapis.com> name: ory_session_{name} path: / persistent: false same_site: Lax lifespan: 720h # Set to 30 days, for example After updating the configuration, apply it to your project using the Ory CLI: bash ory update identity-config --project <project-id> --workspace <workspace-id> --file identity-config.yaml The lifespan value determines how long the session token (for native apps) or session cookie (for browsers) remains valid before the user must re-authenticate. You can use hours (h), minutes (m), and seconds (s) to define the interval (e.g., 72h, 10m, 1h13m3s). Note: This setting affects all sessions, including those for native apps. There is no separate session lifespan setting specifically for native app tokens; the same configuration applies to both session types[Session lifespan](https://www.ory.sh/docs/kratos/session-management/session-lifespan). If you want to allow sessions to be refreshed (extended) before they expire, you can also adjust the earliest_possible_extend setting in your configuration[Refresh threshold](https://www.ory.sh/docs/kratos/session-management/refresh-extend-sessions#refresh-threshold). If you need more granular control (such as privileged session duration), see the [privileged sessions documentation](https://www.ory.sh/docs/kratos/session-management/session-lifespan#privileged-sessions).rough-airplane-18783
07/17/2025, 12:42 PMrough-airplane-18783
07/17/2025, 12:42 PMbrief-egg-61061
07/17/2025, 12:42 PMbrief-egg-61061
07/17/2025, 12:42 PMrefresh=true query parameter. This will prompt the user to re-authenticate, and upon successful login, the session's authenticated_at and expires_at will be updated. Endpoint: GET /self-service/login/api?refresh=true This is the recommended way for native/mobile apps to refresh a session, as it ensures the user is still present and authorized. [See: Refreshing a session](https://www.ory.sh/docs/kratos/self-service/flows/user-login#refreshing-a-session) --- ### 2. Administrator-Initiated Session Extension If you have administrative privileges, you can programmatically extend a user's session using the [Extend Session API](https://www.ory.sh/docs/reference/api#tag/identity/operation/extendSession). Go SDK Example: go session, _, err = ory.IdentityApi.ExtendSession(ContextWithToken(ctx), sessionId). Execute() You need the session ID, which you can obtain by calling the /sessions/whoami endpoint or using the toSession SDK method. [See: Refreshing sessions as administrator](https://www.ory.sh/docs/kratos/session-management/refresh-extend-sessions) --- Note: - Ory does not use "refresh tokens" in the OAuth2 sense for session tokens. Instead, session refresh is handled by re-authentication or admin extension. - For OAuth2 access/refresh tokens, see the [OAuth2 refresh token grant documentation](https://www.ory.sh/docs/oauth2-oidc/refresh-token-grant). If you need to allow users to refresh their session before it expires, ensure your configuration allows it by setting the earliest_possible_extend property appropriately[Refresh threshold](https://www.ory.sh/docs/kratos/session-management/refresh-extend-sessions#refresh-threshold).rough-airplane-18783
10/24/2025, 10:44 AMchilly-king-10285
10/24/2025, 10:44 AMchilly-king-10285
10/24/2025, 10:45 AM/self-service/login/browser which is the browser endpoint. Based on our previous conversation about native apps, if you're building a mobile/native app, you should be using: GET /self-service/login/api The browser endpoint is specifically designed for browser-based flows and requires cookies and CSRF protection. [See: Create Login Flow for Browsers](https://www.ory.sh/docs/kratos/self-service/flows/user-login#initialize-login-flow) ## Common Causes of 500 Errors 1. Domain Configuration Issues: Ensure that Ory and your UI are hosted on the same top-level domain. According to the documentation: > "Ory and your UI must be hosted on the same top level domain. You can't host Ory and your UI on separate top level domains" [Initialize login flow](https://www.ory.sh/docs/kratos/self-service/flows/user-login#initialize-login-flow) 2. CORS and Cookie Issues: If you're making AJAX requests, ensure cookies are included and CORS is properly configured. [See: CSRF troubleshooting](https://www.ory.sh/docs/troubleshooting/csrf) 3. Invalid return_to URL: The return_to parameter must be an allow-listed URL in your project configuration. If it's not allowed, you may get errors. The error security_identity_mismatch indicates: > "The requested ?return_to address is not allowed to be used. Adjust this in the configuration!" [Create Browser Login Flow](https://raw.githubusercontent.com/ory/docs/master/docs/reference/api.json) ## Recommended Actions 1. Check your logs: Enable detailed logging in your Kratos configuration to see the actual error: yaml log: format: text leak_sensitive_values: true 2. Verify your configuration: Ensure your return_to URL (/) is in the allowed return URLs list in your Kratos configuration. 3. Use the correct endpoint: If you're building a native app, switch to /self-service/login/api instead of /self-service/login/browser. 4. Test without parameters: Try calling the endpoint without the return_to parameter to isolate the issue: <https://test.com/api/.ory/self-service/login/browser> If you can share the error logs from your Kratos instance, I can provide more specific guidance on what's causing the 500 error.