i have an api that lets users perform text-to-spee...
# talk-kratos
a
i have an api that lets users perform text-to-speech. A new user is given 10 credits for this api call. Lets say I use ory.sh to authenticate and get a session object, what parameter do i need to pass to backend api to identify the user? I shouldn’t just pass in the identity.id right? Do I pass in the session id? And how do i know which identity id the session id belongs to on my backend?
p
Hi @agreeable-traffic-30717 Please take a look at this document https://www.ory.sh/docs/identities/sign-in/check-session-token-cookie-api
Your backend will pass along the session cookie to Ory and verify the validity of the session. Within the Session is the identity ID.
a
so based on the example docs, the backend passes all values on the cookie. this is alright? i’ll give it a try i guess.
Copy code
const session = await ory
    .toSession({
      cookie: req.cookies.join("; "),
      xSessionToken: sessionToken,
    })
    .catch((err) => {
      // Check the error to see if it's a 401 / 403 -> not logged in
    })
actually, im using python for the backend, is there a way to do this properly with curl? The docs dont have any curl/python examples