quaint-animal-23223
07/17/2024, 1:04 PMchilly-king-10285
07/17/2024, 1:04 PMchilly-king-10285
07/17/2024, 1:05 PM<http://127.0.0.1/sessions/whoami>
endpoint. This endpoint will return the identity details of the user, including the traits. Here is an example of how to do this using curl: bash curl -s -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ <https://playground.projects.oryapis.com/sessions/whoami> | jq
Replace YOUR_ACCESS_TOKEN
with the actual access token. The response will be a JSON object that includes the user's traits among other details. Please note that the URL <https://playground.projects.oryapis.com/sessions/whoami>
is just an example. You should replace it with the actual URL of your Ory instance. For more details, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-login#api-clients).chilly-king-10285
07/17/2024, 1:06 PMchilly-king-10285
07/17/2024, 1:07 PMjavascript import { Configuration, OAuth2Api } from "@ory/client" const ory = new OAuth2Api( new Configuration({ basePath: `https://${process.env.ORY_PROJECT_SLUG}.<http://projects.oryapis.com|projects.oryapis.com>`, accessToken: process.env.ORY_API_KEY, }), ) export async function introspectToken(accessToken: string) { const { data } = await ory.introspectOAuth2Token({ token: accessToken }) // data.active will be true or false // data.ext will contain the user's traits }
In this example, replace ORY_PROJECT_SLUG
and ORY_API_KEY
with your actual project slug and API key. The introspectToken
function will return the token introspection response which includes the user's traits in the ext
field. Please note that this is just an example and the actual implementation may vary depending on your setup. For more details, you can refer to the [Ory Hydra documentation](https://www.ory.sh/docs/hydra/guides/oauth2-token-introspection).