gentle-summer-63235
09/25/2025, 7:03 AMchilly-king-10285
09/25/2025, 7:03 AMchilly-king-10285
09/25/2025, 7:04 AMsession
hook, which issues a session immediately after successful registration. This is also automatically done for social sign-in providers. However, this does not apply to existing users who have not just registered or signed in via OIDC; it is specifically for the registration flow or social sign-in flow, not for arbitrary session creation for existing users without authentication steps [Sign in after registration](https://www.ory.sh/docs/actions/session). - Passwordless/One-Time Code: If you have enabled passwordless authentication (e.g., via email or SMS one-time code), the user can authenticate without a password, but they still need to complete the authentication flow by entering the code sent to them. The server cannot create a session for the user without this user interaction [Email and SMS one-time-code authentication](https://www.ory.sh/docs/kratos/passwordless/one-time-code). - No Direct Session Creation API: There is no documented API or method in Ory Kratos or Ory Network that allows a server to arbitrarily create a session for an existing user without some form of user authentication (password, code, or social login). This is by design, to prevent security risks such as account takeover. Summary: You cannot programmatically create a session for an existing email-user from your server without the user authenticating through a supported login method (password, code, or social login). This is a security measure enforced by Ory's architecture. If you have a specific use case (such as migration from another system), you may need to look into account linking or migration flows, but these still require some form of user authentication or verification [Account linking on login and registration](https://www.ory.sh/docs/kratos/social-signin/link-multiple-provider-account#account-linking-on-login-and-registration). If you need further clarification or have a unique scenario, please provide more details.gentle-summer-63235
09/25/2025, 8:48 AMgentle-summer-63235
09/25/2025, 8:48 AMchilly-king-10285
09/25/2025, 8:48 AMchilly-king-10285
09/25/2025, 8:48 AMgentle-summer-63235
09/25/2025, 8:50 AMchilly-king-10285
09/25/2025, 8:50 AMchilly-king-10285
09/25/2025, 8:50 AMgentle-summer-63235
09/25/2025, 8:54 AMchilly-king-10285
09/25/2025, 8:54 AMchilly-king-10285
09/25/2025, 8:54 AMgentle-summer-63235
09/26/2025, 7:59 AMredirect_uri
we get from Ory.
We are then presented with a page that says:
What happened?
no resumable session found
The browser does not contain the necessary cookie to resume the session. This is a security violation and was blocked. Please clear your browser's cookies and cache and try again!
Is there a common pitfall here? Is this CORS-related or something else? Are we forgetting to do something on our end?chilly-king-10285
09/26/2025, 7:59 AMchilly-king-10285
09/26/2025, 8:00 AMory_kratos_continuity
cookie must be set and available to Ory after the redirect. If your OIDC provider is implemented within your Next.js app and the redirect does not preserve this cookie (e.g., due to domain or path issues), Ory cannot resume the session [Github Issue: ory_kratos_continuity cookie has no domain set](https://github.com/ory/kratos/issues/2713). 4. Redirect URI Handling: Ensure that after authenticating with BankId, your OIDC provider redirects the user back to the exact redirect_uri
provided by Ory, without any intermediate redirects that could lose cookies. What you should check: - Make sure your frontend, Ory Network, and OIDC provider are all on the same (sub)domain, or that cookies are set for the correct domain. - Verify that the ory_kratos_continuity
cookie is present in the browser before and after the redirect. - Check your CORS and cookie settings, especially if you are using custom domains or running locally. - Avoid any extra redirects between the OIDC provider and the Ory redirect URI. Summary: This is most likely a cookie domain or continuity cookie issue, not a CORS problem per se. Double-check your domain setup and ensure the continuity cookie is preserved throughout the flow [Cookie-based security model](https://www.ory.sh/docs/security-model) [Github Issue: ory_kratos_continuity cookie has no domain set](https://github.com/ory/kratos/issues/2713). If you continue to have issues, reviewing the browser's cookie storage and network requests (using browser dev tools) can help pinpoint where the cookie is lost.gentle-summer-63235
09/26/2025, 9:25 AMchilly-king-10285
09/26/2025, 9:25 AMchilly-king-10285
09/26/2025, 9:25 AMlocalhost
) as your frontend application. This setup ensures that cookies—including the continuity cookie—are set and read on the same domain, which is required for the flow to work correctly. How to use Ory Tunnel for local development: 1. Start your frontend app on <http://localhost:3000>
(or your chosen port). 2. Start the Ory Tunnel with the following command (replace <project-id>
with your Ory project ID): ory tunnel --project <project-id> <http://localhost:3000>
This will expose Ory APIs at <http://localhost:4000>
. You should now access your app via <http://localhost:4000>
instead of <http://localhost:3000>
. 3. Configure your Ory SDK (e.g., @ory/client-fetch
) to use <http://localhost:4000>
as the base URL for Ory API calls. 4. **Always use either localhost
or 127.0.0.1
consistently**—do not mix them, as browsers treat them as different domains and cookies will not be shared between them. By following this approach, both your app and Ory Network will operate under the same domain (localhost
), and the continuity cookie will be available throughout the authentication flow, preventing the "no resumable session found" error [Local development](https://www.ory.sh/docs/getting-started/local-development#local-development) [Ory Tunnel](https://www.ory.sh/docs/cli/ory-tunnel#ory-tunnel) [Ory Proxy and Ory Tunnel](https://www.ory.sh/docs/guides/cli/proxy-and-tunnel). Summary: Use Ory Tunnel and access your app through the tunnel's port to ensure domain consistency and proper cookie handling during local development with Ory Network.gentle-summer-63235
09/26/2025, 9:42 AMchilly-king-10285
09/26/2025, 9:42 AMchilly-king-10285
09/26/2025, 9:42 AMlocalhost
) and public (ngrok) domains. This can cause issues with cookies, especially the continuity cookie, because Ory Network and your frontend (running on localhost
via Ory Tunnel) expect all parts of the flow—including redirects—to happen on the same domain. Key points from the knowledge sources: - Ory's security model and session management require that all services involved in the authentication flow (frontend, Ory APIs, and OIDC provider) operate under the same domain for cookies to be set and read correctly. Mixing domains (e.g., localhost
and an ngrok URL) can break the flow, resulting in errors like "no resumable session found" [Cookie-based security model](https://www.ory.sh/docs/security-model) [Local development](https://www.ory.sh/docs/getting-started/local-development#local-development). - For local development, Ory recommends using Ory Tunnel to ensure both your app and Ory APIs are available on the same domain (localhost
). However, the knowledge sources do not provide a documented solution for running a local OIDC provider that must be accessible both to Ory Network (via a public URL like ngrok) and to your local frontend (via localhost
) in a way that preserves cookies across the entire flow. Summary: The knowledge sources do not describe a supported or recommended way to run a local OIDC provider exposed via ngrok while maintaining domain consistency for cookies with Ory Network and your local frontend. This split-domain setup is likely to cause the continuity cookie issue you are experiencing. For local development, all components should ideally run under the same domain, but exposing a local OIDC provider to Ory Network via ngrok breaks this requirement. If you need to test with Ory Network (not self-hosted), you may need to deploy your OIDC provider to a public environment where it can share a domain or subdomain with your frontend and Ory APIs, or wait until you can use a production-like setup with custom domains as described in the documentation [Set up custom domains](https://www.ory.sh/docs/guides/custom-domains). If you must use ngrok: Be aware that this setup is not fully supported for cookie/session flows, and you may continue to encounter issues until all services are on the same domain or subdomain.gentle-summer-63235
09/26/2025, 9:47 AMchilly-king-10285
09/26/2025, 9:47 AMchilly-king-10285
09/26/2025, 9:47 AMoauth2: "server_error"
indicates that the authorization server (Ory Network) encountered an unexpected condition that prevented it from fulfilling the request. This is a generic error and, by default, does not provide detailed information to avoid exposing sensitive details. To see more information about the error for debugging purposes, you can switch your Ory project to development mode. In development mode, the error response will include an error_debug
field with more details about what went wrong. For example: json { "error": "error", "error_description": "The error is unrecognizable", "status_code": 500, "error_debug": "Token is expired" }
This can help you identify the root cause of the issue. Remember that in production mode, detailed debug information is not included in the response for security reasons [Solutions for common OAuth2-related problems](https://www.ory.sh/docs/hydra/debug#refresh-token-flow-fails). If you are not seeing the error_debug
field, ensure your project is in development mode. If you still need more information, you may need to check your OIDC provider's logs or configuration for additional clues. Summary: - server_error
is a generic error from the authorization server. - Switch to development mode to see more detailed error information in the response. - Check your OIDC provider logs for further details if needed.gentle-summer-63235
09/26/2025, 12:08 PMlocal claims = {
email_verified: false
} + std.extVar('claims');
{
identity: {
traits: {
// Map BankID data to your identity schema
email: claims.email,
name: claims.name,
personal_number: claims.personal_number,
},
},
}
Is this looking correct? The email, name and personal_number should come from the JWT-token that is generated by the token endpoint correct?
How should they be placed in the token, in the payload root?chilly-king-10285
09/26/2025, 12:08 PMchilly-king-10285
09/26/2025, 12:08 PMemail
, name
, and personal_number
. Regarding where the claims should be in the JWT token: Yes, the email
, name
, and personal_number
should be present in the payload (root) of the ID token (the JWT returned by your OIDC provider's token endpoint). Ory expects to find these claims at the top level of the decoded JWT payload, as shown in the standard OIDC example: json { "iss": "<https://my-domain.projects.oryapis.com>", "sub": "some-identity-id", "aud": "some-client-id", "exp": 1311281970, "iat": 1311280970, "nonce": "KxSty13b2L", "name": "Jane Doe", "email": "<mailto:jane@example.org|jane@example.org>", "email_verified": true }
You can add custom claims (like personal_number
) at the root level in the same way. Your OIDC provider should include these claims in the ID token payload so that Ory can access them via std.extVar('claims')
in your Jsonnet mapping [The ID Token](https://www.ory.sh/docs/oauth2-oidc/overview/oidc-concepts#the-id-token) [Write a Jsonnet data mapper](https://www.ory.sh/docs/kratos/social-signin/data-mapping#write-a-jsonnet-data-mapper). Summary: - Your mapping is correct if your identity schema matches. - The claims (email
, name
, personal_number
) should be at the root of the ID token payload. - Ory will access them as claims.email
, claims.name
, and claims.personal_number
in your Jsonnet code. If you need to map claims from a nested object, you would need to adjust your Jsonnet accordingly, but for standard and custom claims at the root, your current approach is correct.gentle-summer-63235
09/26/2025, 12:13 PM<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Details>
No such object: bac-gcs-production/86cb9ff4f32a823d4378b70233f8440b108e3e94edc3f12bd588c166489d9a788e8293aa5786cebf187ab504c3c9d272654f67da9481ef10a290e1f526f4620d.jsonnet:11:24-46
</Details>
</Error>
This is the token payload from the ID-token:
{
"sub": "a54491f1-7e7a-40c7-8c39-09a3dff3829a",
"aud": "platzer-portal-bankid",
"iss": "<https://platzer.ngrok.app/api/oauth2/bankid>",
"iat": 1758888322,
"exp": 1758891922,
"email": "<mailto:197807075788@bankid.platzer.se|197807075788@bankid.platzer.se>",
"personal_number": "197807075788",
"external_account_id": "abc123",
"name": "BankID User 197807075788"
}
Any idea why it is not finding personal_number
?chilly-king-10285
09/26/2025, 12:13 PMchilly-king-10285
09/26/2025, 12:13 PMpersonal_number
field at the root, which matches your Jsonnet mapping. However, the error message from Ory: jsonnetsecure: ERROR: RUNTIME ERROR: Field does not exist: personal_number
indicates that, at runtime, the personal_number
field is not present in the claims
object as seen by the Jsonnet mapper. Possible causes and troubleshooting steps based on the knowledge sources: 1. Claims May Be Missing or Not Passed as Expected Ory passes the claims from the ID token to the Jsonnet mapper as std.extVar('claims')
. If the field is missing, referencing it directly will cause a runtime error. The recommended approach is to use optional field access in Jsonnet to avoid errors if a field is missing [Data mapping with Jsonnet](https://www.ory.sh/docs/kratos/reference/jsonnet): jsonnet local claims = { email_verified: false } + std.extVar('claims'); { identity: { traits: { email: claims.email, name: claims.name, [if "personal_number" in claims then "personal_number" else null]: claims.personal_number, }, }, }
This way, if personal_number
is missing, it won't cause a runtime error. 2. Debugging Claims Received by Ory To debug what Ory actually receives, you can temporarily add all claims to metadata_public
in your Jsonnet mapping. This is suggested in the troubleshooting guide for social sign-in mapping issues [Troubleshooting social sign-in](https://www.ory.sh/docs/troubleshooting/troubleshooting-social-sign-in#redirect-loops-after-registration): jsonnet local claims = { email_verified: false } + std.extVar('claims'); { identity: { traits: { email: claims.email, name: claims.name, [if "personal_number" in claims then "personal_number" else null]: claims.personal_number, }, metadata_public: { debug_claims: claims } }, }
After a test login, inspect the created identity in Ory to see exactly what claims are present. 3. Token Claims Source Ensure that your OIDC provider configuration in Ory is set to use the correct claims source. By default, Ory reads claims from the id_token
, but you can also set it to use the userinfo
endpoint. If your provider does not support the userinfo
endpoint or does not return all claims there, make sure claims_source
is set to id_token
[Generic provider additional configuration](https://www.ory.sh/docs/kratos/social-signin/generic#additional-configuration): yaml claims_source: id_token
Summary: - Use optional field access in your Jsonnet mapping to avoid runtime errors if a claim is missing. - Temporarily output all claims to metadata_public
to debug what Ory actually receives. - Ensure your OIDC provider config in Ory is set to use the correct claims source. If after these steps the field is still missing, it may indicate an issue with how the OIDC provider is generating or returning the ID token, or how Ory is configured to read the claims. The knowledge sources do not provide further details on debugging beyond these steps.gentle-summer-63235
09/26/2025, 12:52 PM"credentials": {
"oidc": {
"config": {
"providers": [
{
"provider": "bankid",
"subject": "<mailto:the-email@example.org|the-email@example.org>",
"use_auto_link": true
}
]
}
}
}
chilly-king-10285
09/26/2025, 12:52 PMchilly-king-10285
09/26/2025, 12:53 PMpatchIdentity
) API. The PATCH API is intended for partial updates, such as changing traits or schema, but not for modifying credentials. The documentation and community discussions explicitly state that credentials cannot be changed using a PATCH operation [Is credentials patching supported?](https://github.com/ory/kratos/discussions/4395). However, you can update credentials using the PUT (updateIdentity
) API. The updateIdentity
endpoint allows you to provide the full identity payload, and if you include the credentials
field, the credentials will be imported and added to the existing credentials of the identity. This means you can add or update OIDC providers (including setting use_auto_link: true
) for an existing identity using the updateIdentity
endpoint [Ory API Reference – updateIdentity](https://raw.githubusercontent.com/ory/docs/master/docs/reference/api.json) [Kratos API Reference – updateIdentity](https://raw.githubusercontent.com/ory/kratos/master/spec/api.json). Example payload for `updateIdentity`: json { "schema_id": "<preset://email>", "traits": { "email": "<mailto:the-email@example.org|the-email@example.org>" }, "state": "active", "credentials": { "oidc": { "config": { "providers": [ { "provider": "bankid", "subject": "<mailto:the-email@example.org|the-email@example.org>", "use_auto_link": true } ] } } } }
Summary: - You cannot use the PATCH API to update credentials or add OIDC providers. - You can use the PUT (updateIdentity
) API to update credentials, including adding OIDC providers with use_auto_link: true
[Ory API Reference – updateIdentity](https://raw.githubusercontent.com/ory/docs/master/docs/reference/api.json). If you need to update credentials for multiple users, consider using the batch patch endpoint, but ensure you follow the documented structure for credentials updates.gentle-summer-63235
09/26/2025, 12:55 PM{
"error": {
"code": 409,
"status": "Conflict",
"request": "a2b736f5-92ce-9482-9187-4319cc664374",
"message": "Unable to insert or update resource because a resource with that value exists already"
}
}
Not sure exactly what value it is referring to. The Identity already have credentials, since the email account already exists. Is that what is mentioned?chilly-king-10285
09/26/2025, 12:55 PMchilly-king-10285
09/26/2025, 12:55 PMjson { "error": { "code": 409, "status": "Conflict", "request": "a2b736f5-92ce-9482-9187-4319cc664374", "message": "Unable to insert or update resource because a resource with that value exists already" } }
indicates a 409 Conflict. According to the knowledge sources, this error typically occurs when you attempt to insert or update a resource with a value that must be unique, but that value already exists in the system. In the context of identities and credentials, this usually means that one of the identifiers (such as an email address or an OIDC subject) is already associated with another identity or credential in the system. For OIDC credentials, each identifier (e.g., the combination of provider
and subject
) must be unique across all identities. If you try to add an OIDC provider/subject pair that is already linked to another identity, or if the email identifier is already used in another credential type in a way that violates uniqueness, you will get this error [Docs: Credentials](https://www.ory.sh/docs/kratos/concepts/credentials) [Docs: Errors during bulk import](https://www.ory.sh/docs/kratos/manage-identities/import-user-accounts-identities#errors-during-bulk-import). Summary: - The error refers to a uniqueness conflict, most likely with the OIDC provider/subject pair or the email identifier. - This can happen if the identity already has credentials with the same identifier, or if another identity in the system does. If you need to resolve this, check if the OIDC provider/subject or email is already linked to another identity or credential. You may need to remove or update the conflicting credential before proceeding. If you need more specific details about which value is causing the conflict, the knowledge sources do not provide a way to get more granular error information from the API response.gentle-summer-63235
09/26/2025, 12:58 PMautolink: true
for our own OIDC?
Basically make sure this is set when the account has been created initially:
"oidc": {
"config": {
"providers": [
{
"provider": "bankid",
"subject": "the-email@<http://example.org|example.org>",
"use_auto_link": true
}
]
}
}
chilly-king-10285
09/26/2025, 12:58 PMchilly-king-10285
09/26/2025, 12:59 PMuse_auto_link: true
for your OIDC provider (e.g., BankId) at the time of email account creation using Ory/nextjs or Ory Network's standard registration flows. The knowledge sources describe how to enable auto-linking by importing or updating an identity with the use_auto_link
flag set for a specific OIDC provider and subject, but this is done via the admin API (such as updateIdentity
or during import), not as part of the self-service registration flow [Account linking on login and registration](https://www.ory.sh/docs/kratos/social-signin/link-multiple-provider-account#account-linking-on-login-and-registration). There is no mention of a configuration option or hook in Ory/nextjs or Ory Network that would automatically add or update OIDC credentials with use_auto_link: true
when a new email/password account is created through the standard user-facing flows. Summary: - The knowledge sources do not describe a way to automatically set use_auto_link: true
for an OIDC provider during email account creation via Ory/nextjs or Ory Network self-service flows. - Setting use_auto_link: true
must be done via the admin API after account creation, or by importing identities with this flag set. If you require this functionality, you would need to implement a custom process that updates the identity after creation using the admin API, but this is not covered in the official documentation.gentle-summer-63235
09/26/2025, 2:02 PMauthorization_endpoint
-field in the openid-configuration file. Any idea why that is happening?chilly-king-10285
09/26/2025, 2:02 PMchilly-king-10285
09/26/2025, 2:03 PMory_kratos_continuity
) is missing or not preserved throughout the flow, Ory cannot resume the registration session and may restart the OIDC authorization process. This is a common pitfall, especially when domains are not consistent or cookies are not set correctly during redirects [Cookie-based security model](https://www.ory.sh/docs/security-model) [Local development](https://www.ory.sh/docs/getting-started/local-development#local-development). 2. Claims Mapping or Data Mapping Issues: If the data mapping (Jsonnet) fails or required traits are missing, Ory may not be able to complete the registration and could restart the flow. The troubleshooting guide suggests outputting all claims to metadata_public
to debug what is being received and mapped [Troubleshooting social sign-in](https://www.ory.sh/docs/troubleshooting/troubleshooting-social-sign-in#redirect-loops-after-registration). 3. Redirect Loops Due to Incomplete Registration: If Ory cannot map all required identity traits from the OIDC provider, it may redirect the user back to the registration page, and if the issue persists, this can result in a loop or restart of the flow [Troubleshooting social sign-in](https://www.ory.sh/docs/troubleshooting/troubleshooting-social-sign-in#redirect-loops-after-registration). 4. Session Not Created After Registration: If the session is not created after registration (e.g., missing the session
hook in the registration flow), the user may be sent back to the start of the flow [Successful registration](https://www.ory.sh/docs/kratos/self-service/flows/user-registration#successful-registration). What you can do: - Ensure the continuity cookie is present and preserved throughout the flow. - Check your Jsonnet data mapping for missing or incorrectly mapped traits. - Temporarily output all claims to metadata_public
to debug what Ory receives. - Make sure the session
hook is enabled in your registration flow configuration if you want users to be logged in immediately after registration. Summary: This issue is most likely related to a missing or invalid continuity cookie, or a problem with claims mapping/data mapping that prevents Ory from completing the registration. Double-check your cookie handling, domain setup, and data mapping configuration to resolve the issue [Cookie-based security model](https://www.ory.sh/docs/security-model) [Troubleshooting social sign-in](https://www.ory.sh/docs/troubleshooting/troubleshooting-social-sign-in#redirect-loops-after-registration).