billions-minister-2901
04/03/2025, 6:02 PMbrief-egg-61061
04/03/2025, 6:02 PMbrief-egg-61061
04/03/2025, 6:02 PMperformNativeLogout
API endpoint: go func Logout(ctx context.Context, sessionToken string) error { _, err := ory.FrontendApi.PerformNativeLogout(ctx). PerformNativeLogoutBody(*client.NewPerformNativeLogoutBody(sessionToken)). Execute() if err != nil { return err } // Logout was successful return nil }
This endpoint expects the session token to be provided in the request body. When successfully executed, it will invalidate the session token, effectively logging the user out. [Ory Kratos SDK Go Documentation](https://www.ory.sh/docs/kratos/sdk/go#perform-logout-flow) ## For Browser-Based Applications For browser-based applications, you should use the createBrowserLogoutFlow
endpoint to generate a logout URL: javascript const logoutUrl = await ory .frontend.createBrowserLogoutFlow() .then(({ data }) => data.logout_url)
The user can then be redirected to this URL to complete the logout process. [SDK V1 Upgrade Guide](https://www.ory.sh/docs/guides/upgrade/sdk-v1#logout-for-browser-apps) ## Additional Considerations 1. Session Management: When implementing logout, remember that Ory maintains different session layers, especially when using OAuth2/OpenID Connect. You may need to handle multiple session layers depending on your setup. 2. Revoking Specific Sessions: If you want to revoke a specific session rather than the current one, you can use the disableMySession
API: typescript await frontend.disableMySession({ id: sessionId, xSessionToken: token, })
[Session Management Documentation](https://www.ory.sh/docs/kratos/session-management/list-revoke-get-sessions#revoking-a-specific-session) 3. Revoking All Other Sessions: You can also revoke all sessions except the current one: typescript await frontend.disableMyOtherSessions({ xSessionToken: token, })
[Session Management Documentation](https://www.ory.sh/docs/kratos/session-management/list-revoke-get-sessions#revoking-all-other-sessions) Choose the approach that best fits your application type and requirements.