gorgeous-motorcycle-71764
09/22/2025, 5:28 AMchilly-king-10285
09/22/2025, 5:28 AMchilly-king-10285
09/22/2025, 5:29 AMts // Express-style pseudo code import { Configuration, FrontendApi, OAuth2Api } from "@ory/client" const kratos = new FrontendApi(new Configuration({ basePath: process.env.ORY_SDK_URL })) const hydra = new OAuth2Api(new Configuration({ basePath: process.env.ORY_SDK_URL })) app.get("/logout", async (req, res) => { try { // 1) Create Kratos browser logout flow const { data: { logout_url } } = await kratos.createBrowserLogoutFlow({ cookie: req.header("cookie") || "", // return_to can be provided if desired // returnTo: "<https://your-app.example.com/post-logout>", }) // 2) Redirect to Kratos logout URL (completes Kratos logout) // After this redirect completes, user returns to your app (per return_to/default). res.redirect(logout_url) } catch { // even if Kratos logout fails, try Hydra logout to clean up OIDC sessions res.redirect("/logout/hydra") } }) app.get("/logout/hydra", async (req, res) => { // 3) Trigger Hydra OIDC logout (OP-initiated) // If you use RP-initiated, add id_token_hint/state/post_logout_redirect_uri in the query. // This call returns 302 and Hydra will handle redirects and front/back-channel. res.redirect("/oauth2/sessions/logout") })
- The Kratos API usage and redirect pattern are shown in official examples. [[Sign out](https://www.ory.sh/docs/identities/get-started/sign-out)] - Hydra’s logout endpoint is GET /oauth2/sessions/logout and drives front-/back-channel logout. [[Hydra revokeOidcSession](https://raw.githubusercontent.com/ory/hydra/master/spec/api.json); [OIDC logout](https://www.ory.sh/docs/oauth2-oidc/oidc-logout); [Hydra debug logout](https://www.ory.sh/docs/hydra/debug/logout)] If you need a custom Hydra logout UI/endpoint (e.g., to require user confirmation), implement it using getOAuth2LogoutRequest, acceptOAuth2LogoutRequest, rejectOAuth2LogoutRequest as shown in the guide. [[Hydra logout guide](https://www.ory.sh/docs/hydra/guides/logout)]gorgeous-motorcycle-71764
09/23/2025, 5:51 AMHydraAdminClient.AdminApi.RevokeAuthenticationSession
gorgeous-motorcycle-71764
09/23/2025, 5:51 AMHydraAdminClient.AdminApi.RevokeAuthenticationSession
chilly-king-10285
09/23/2025, 5:51 AMchilly-king-10285
09/23/2025, 5:52 AMgorgeous-motorcycle-71764
09/23/2025, 6:09 AMchilly-king-10285
09/23/2025, 6:09 AMchilly-king-10285
09/23/2025, 6:09 AMgorgeous-motorcycle-71764
09/23/2025, 6:16 AMchilly-king-10285
09/23/2025, 6:16 AMchilly-king-10285
09/23/2025, 6:16 AMgorgeous-motorcycle-71764
09/23/2025, 7:37 AMchilly-king-10285
09/23/2025, 7:37 AMchilly-king-10285
09/23/2025, 7:37 AMgorgeous-motorcycle-71764
09/23/2025, 9:20 AMchilly-king-10285
09/23/2025, 9:20 AMchilly-king-10285
09/23/2025, 9:20 AM/oauth2/sessions/logout
API (OpenID Connect logout endpoint), the following query parameters are supported: - id_token_hint
(optional): The ID Token previously issued to the user. Including this helps Hydra identify the user session to log out, especially if the session cookie is missing or the login was not remembered. - post_logout_redirect_uri
(optional): The URL to which the user should be redirected after logout. This must be whitelisted in the OAuth2 client’s configuration. - state
(optional): A value used to maintain state between the logout request and the response. If provided, it will be returned in the redirect after logout. Cookies: - If the user has an active authentication session, the browser must send the oauth2_authentication_session
cookie for the domain where Hydra is running. This cookie is used to identify the user’s session for logout. If the cookie is missing (e.g., due to strict browser privacy settings or if the login was not remembered), Hydra may not be able to identify the session unless id_token_hint
is provided [[Hydra debug logout](https://www.ory.sh/docs/hydra/debug/logout); [Send the ID token in id_token_hint](https://www.ory.sh/docs/oauth2-oidc/oidc-logout#send-the-id-token-in-id_token_hint)]. Summary Table: | Query Parameter | Required | Description | |----------------------------|----------|-----------------------------------------------------------------------------| | id_token_hint | No | ID Token to help identify the session to log out | | post_logout_redirect_uri | No | Redirect URL after logout (must be whitelisted) | | state | No | Opaque value to maintain state between request and response | | Cookie | Required | Description | |-------------------------------|----------|--------------------------------------------------| | oauth2_authentication_session | No* | Identifies the user session for logout | \* Required if you want Hydra to identify the session without id_token_hint
. References: [Hydra debug logout](https://www.ory.sh/docs/hydra/debug/logout) [Send the ID token in id_token_hint](https://www.ory.sh/docs/oauth2-oidc/oidc-logout#send-the-id-token-in-id_token_hint)gorgeous-motorcycle-71764
09/25/2025, 6:34 AMchilly-king-10285
09/25/2025, 6:34 AMchilly-king-10285
09/25/2025, 6:34 AMsub
(subject) claim in Hydra's issued JWT. By default, Hydra uses the subject value you provide during the login acceptance as the JWT's sub
claim. So, if you pass the mobile number as the subject, the JWT's sub
field will be set to that mobile number. Example: - User logs in with mobile number +1234567890
via Kratos (code method). - You accept the Hydra login challenge and set subject: "+1234567890"
. - Hydra issues a JWT with "sub": "+1234567890"
. There is no automatic mapping or transformation unless you implement it yourself or configure Hydra/Kratos to use a different identifier (such as external_id
). The subject is what you provide when accepting the login request [[Hydra subject claim](https://www.ory.sh/docs/hydra/guides/openid)]. If you want the JWT's sub
claim to be something else (e.g., an internal user ID or an external ID), you must provide that value as the subject when accepting the login request. Otherwise, it will be the mobile number you used as the identifier.gorgeous-motorcycle-71764
09/25/2025, 1:21 PMchilly-king-10285
09/25/2025, 1:21 PMchilly-king-10285
09/25/2025, 1:21 PMgo func DisableAndDeleteSessions(ctx context.Context, identityId string) (err error) { _, err = ory.IdentityApi.DeleteIdentitySessions(ContextWithToken(ctx), identityId). Execute() return err }
This function calls the DeleteIdentitySessions
method on the IdentityApi
, passing the identity ID. This irrecoverably and permanently deletes and invalidates all sessions that belong to the given identity [[Delete sessions](https://www.ory.sh/docs/kratos/sdk/go#delete-sessions); [Revoke and delete sessions of a user](https://www.ory.sh/docs/kratos/session-management/list-revoke-get-sessions#revoke-and-delete-sessions-of-a-user)]. API Reference: DELETE /admin/identities/{id}/sessions
[[API reference](https://raw.githubusercontent.com/ory/kratos/master/spec/api.json)]gorgeous-motorcycle-71764
09/27/2025, 8:32 AMchilly-king-10285
09/27/2025, 8:32 AMchilly-king-10285
09/27/2025, 8:32 AMAdminApi.GetLoginRequest
function in the Hydra client SDK. There is no direct troubleshooting guide or documented error message for this specific issue in the provided documentation or API references. However, based on the available API references, the correct endpoint for fetching a login request is GET /admin/oauth2/auth/requests/login
and it requires the login_challenge
query parameter to be set. If this parameter is missing or incorrect, or if the SDK function is not called with the expected arguments, it could potentially result in errors or unexpected responses [[Hydra getOAuth2LoginRequest](https://raw.githubusercontent.com/ory/hydra/master/spec/api.json); [Ory API getOAuth2LoginRequest](https://raw.githubusercontent.com/ory/docs/master/docs/reference/api.json)]. If you are seeing an "undefined response type" error, please ensure: - You are passing the required login_challenge
parameter. - You are using the correct SDK function and version. - The Hydra server is running and accessible. If the issue persists, it may be a bug or a mismatch between the SDK and the Hydra server version. In that case, consider checking the SDK documentation or opening an issue in the [Ory Hydra SDKs GitHub repository](https://github.com/ory/sdk/tree/master/clients/hydra/) for further assistance [[Hydra SDK overview](https://www.ory.sh/docs/hydra/sdk/overview)]. I'm sorry I can't provide a more specific answer based on the current knowledge sources.