billions-minister-2901
04/16/2024, 3:40 PMchilly-king-10285
04/16/2024, 3:40 PMchilly-king-10285
04/16/2024, 3:41 PM/.well-known/jwks.json
. If your ES256 key is not appearing in the JWKS, it could be due to a variety of reasons such as issues with key generation or key rotation. You can generate keys for production using the Ory CLI and the command ory create jwk some-example-set --alg ES256 --project {project.id} --format json-pretty
. If the key set contains more than one key, the first key in the list will be used for signing. For key rotation, you can use the JSON Web Keys API, which provides endpoints for generating and managing JWKs. Regular rotation of cryptographic keys is recommended for maximum security. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/hydra/jwks) on cryptographic key management and JSON Web Key Sets (JWKS).billions-minister-2901
04/16/2024, 4:39 PMsessions/whoami?tokenize_as
I'm receiving:
{
"error": {
"code": 400,
"status": "Bad Request",
"request": "f461e98a-e07a-9a3d-a713-691f0f2ce8a8",
"reason": "Unable to sign JSON Web Token.",
"message": "The request was malformed or contained invalid parameters"
}
}
chilly-king-10285
04/16/2024, 4:39 PMchilly-king-10285
04/16/2024, 4:39 PMsessions/whoami
endpoint. The error message "Unable to sign JSON Web Token" suggests that there might be a problem with the tokenization process. When calling the sessions/whoami
endpoint, you're supposed to include a session token or forward the HTTP Cookie Header if you're calling from a server-side application. If you're calling from a non-browser application, you must include the session token. Here's an example of how to do it: js // pseudo-code example const session = await client.toSession("the-session-token") console.log(session)
When using a token template, the token is included in the tokenized
field of the session. Here's an example: js // pseudo-code example const session = await client.toSession("the-session-token", { tokenize_as: "example-jwt-template" })
The tokenize_as
parameter should be set to a valid tokenize template. If it's not valid, it could cause the error you're seeing. Please ensure that you're following these guidelines when making the request. If the problem persists, it might be due to an issue with the JWT signing process, such as an invalid or missing signing key. For more information, you can refer to the [Ory API Reference](https://www.ory.sh/docs/kratos/reference/api) and the [Ory Identities API](https://www.ory.sh/docs/reference/api).billions-minister-2901
04/16/2024, 4:40 PM"jwt_template": {
"claims_mapper_url": "<https://storage.googleapis.com/bac-gcs-production/e091fd934a8e42e0254f1d60bdce2fc4f54a2c600c51bf59d2bfae5bd54c31deed92c45673f0f819b09921814f2776fa98f6e6aa769ea8ccc88103cf2d79b0f7.jsonnet>",
"jwks_url": "<https://compassionate-cohen-n0elso3els.projects.oryapis.com/.well-known/jwks.json>",
"ttl": "24h0m0s"
}
chilly-king-10285
04/16/2024, 4:40 PMchilly-king-10285
04/16/2024, 4:40 PMclaims_mapper_url
, a jwks_url
, and a ttl
(time-to-live) value. Here's a brief explanation of each field: - `claims_mapper_url`: This is the URL of a JsonNet template that modifies the claims of the JWT. - `jwks_url`: This is the URL where the JSON Web Key Set (JWKS) is fetched from. The JWKS is used to sign and verify the JWT. - `ttl`: This is the time-to-live of the JWT, which specifies how long the JWT is valid for. In your case, it's set to 24 hours. If you're receiving an error when trying to tokenize a session, it could be due to a few reasons: 1. The jwks_url
might not be returning a valid JWKS. You can check this by navigating to the URL in a web browser or using a tool like curl
to fetch the JWKS. 2. The claims_mapper_url
might not be returning a valid JsonNet template. Similar to the JWKS, you can check this by navigating to the URL in a web browser or using a tool like curl
. 3. There might be an issue with the session you're trying to tokenize. Ensure that the session is valid and hasn't expired. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/identities/session-to-jwt-cors#json-web-token-templates) on JSON Web Token templates.