some-painting-28549
04/26/2024, 8:26 AMchilly-king-10285
04/26/2024, 8:26 AMchilly-king-10285
04/26/2024, 8:26 AMpublic_metadatasome-painting-28549
04/26/2024, 8:27 AMchilly-king-10285
04/26/2024, 8:27 AMchilly-king-10285
04/26/2024, 8:28 AM/sessions/whoami401 Unauthorizedpython # pseudo-code example @app.get('/protected-endpoint') async def read_item(request: Request):     cookies = request.cookies     session = await client.toSession(undefined, cookies)     print(session)client.toSessionclientundefinedsome-painting-28549
04/26/2024, 10:19 AMchilly-king-10285
04/26/2024, 10:19 AMchilly-king-10285
04/26/2024, 10:19 AMFrontendApi@ory/clienttoSession200 OKjsx import { Configuration, FrontendApi, Session } from "@ory/client"   import { useEffect, useState } from "react"    const ory = new FrontendApi(    new Configuration({    basePath: `https://{project.slug}.<http://projects.oryapis.com|projects.oryapis.com>`,    }),   )    export default function SomeComponent() {    const [session, setSession] = useState<Session | undefined>()      useEffect(() => {     ory     .toSession()     .then(({ data }) => setSession(data))    }, [])     return <div>{session?.id}</div>   }ory.toSession()useStateuseEffectory.toSession()some-painting-28549
04/26/2024, 10:21 AMchilly-king-10285
04/26/2024, 10:21 AMchilly-king-10285
04/26/2024, 10:21 AM/sessions/whoami401 Unauthorizedpython from fastapi import FastAPI, Request, HTTPException from ory_kratos_client import Configuration, ApiClient, PublicApi  app = FastAPI()  # Initialize the Ory Kratos API client config = Configuration(     host = "<http://path-to-kratos-public-api>" ) with ApiClient(config) as api_client:     public_api = PublicApi(api_client)  @app.get("/protected-endpoint") async def read_item(request: Request):     # Extract the cookie from the request     cookie = request.cookies.get('ory_kratos_session')      # Call the /sessions/whoami endpoint with the cookie     try:         session = public_api.to_session(cookie=cookie)     except ApiException as e:         if e.status == 401:             raise HTTPException(status_code=401, detail="Unauthorized")         else:             raise HTTPException(status_code=500, detail="Internal server error")      # If the session is valid, continue processing the request     # ...public_api.to_sessionApiException"<http://path-to-kratos-public-api>"some-painting-28549
04/26/2024, 10:23 AM${baseUrl}/user/invite${baseUrl}/user/invite${baseUrl}/user/invitesome-painting-28549
04/26/2024, 10:23 AM${baseUrl}/user/invite${baseUrl}/user/invite${baseUrl}/user/invitechilly-king-10285
04/26/2024, 10:23 AMchilly-king-10285
04/26/2024, 10:23 AMcredentials: 'include'Access-Control-Allow-Credentials: trueSecureHttpOnlySet-Cookiesome-painting-28549
04/26/2024, 1:36 PMchilly-king-10285
04/26/2024, 1:36 PMchilly-king-10285
04/26/2024, 1:36 PMupdateIdentityAdminApiUpdateIdentitypython from ory_kratos_client import Configuration, ApiClient, AdminApi, UpdateIdentity  # Initialize the Ory Kratos API client config = Configuration(     host = "<http://path-to-kratos-admin-api>" ) with ApiClient(config) as api_client:     admin_api = AdminApi(api_client)  # Define the new metadata new_metadata = {     "metadata_public": {         "key": "new value"     },     "metadata_admin": {         "key": "new value"     } }  # Create an UpdateIdentity object update_identity = UpdateIdentity(**new_metadata)  # Update the identity admin_api.update_identity("identity-id", update_identity)"<http://path-to-kratos-admin-api>""identity-id""key""new value"/admin/identitiessome-painting-28549
04/26/2024, 1:41 PMchilly-king-10285
04/26/2024, 1:41 PMchilly-king-10285
04/26/2024, 1:41 PMsome-painting-28549
04/26/2024, 1:42 PMchilly-king-10285
04/26/2024, 1:42 PMchilly-king-10285
04/26/2024, 1:43 PMsome-painting-28549
04/26/2024, 1:57 PMchilly-king-10285
04/26/2024, 1:57 PMchilly-king-10285
04/26/2024, 1:57 PMJsonPatchJsonPatchpython patch = [     {         "op": "replace",         "path": "/name",         "value": "New name"     } ]patchname"New name"jsonpatchpython import jsonpatch  # Original JSON document doc = {     "name": "Old name" }  # JSON Patch document patch = [     {         "op": "replace",         "path": "/name",         "value": "New name"     } ]  # Apply the patch new_doc = jsonpatch.apply_patch(doc, patch)  print(new_doc)  # Prints: {"name": "New name"}jsonpatch.apply_patchpatchdocjsonpatchsome-painting-28549
04/26/2024, 2:05 PMchilly-king-10285
04/26/2024, 2:05 PMchilly-king-10285
04/26/2024, 2:05 PMupdateIdentitypython from ory_kratos_client import Configuration, ApiClient, AdminApi, UpdateIdentity  # Initialize the Ory Kratos API client config = Configuration(     host = "<http://path-to-kratos-admin-api>" ) with ApiClient(config) as api_client:     admin_api = AdminApi(api_client)  # Define the new metadata new_metadata = {     "metadata": {         "metadata_public": {             "key": "new value"         },         "metadata_admin": {             "key": "new value"         }     } }  # Create an UpdateIdentity object update_identity = UpdateIdentity(**new_metadata)  # Update the identity admin_api.update_identity("identity-id", update_identity)"<http://path-to-kratos-admin-api>""identity-id""key""new value"/admin/identitiessome-painting-28549
04/26/2024, 2:05 PMchilly-king-10285
04/26/2024, 2:05 PMchilly-king-10285
04/26/2024, 2:06 PMupdateIdentitypython from ory_kratos_client import Configuration, ApiClient, AdminApi, UpdateIdentity  # Initialize the Ory Kratos API client config = Configuration(     host = "<http://path-to-kratos-admin-api>" ) with ApiClient(config) as api_client:     admin_api = AdminApi(api_client)  # Define the new metadata new_metadata = {     "metadata": {         "metadata_public": {             "key": "new value"         }     } }  # Create an UpdateIdentity object update_identity = UpdateIdentity(**new_metadata)  # Update the identity admin_api.update_identity("identity-id", update_identity)"<http://path-to-kratos-admin-api>""identity-id""key""new value"/admin/identities