Hello Everyone, I want to convert my ORY session t...
# ory-network
n
Hello Everyone, I want to convert my ORY session token to JSON Web Token. I applied the configuration from the following document. https://www.ory.sh/docs/identities/session-to-jwt-cors Now I have a valid configuration. I tried to get a JWT in my React Native code. It returns a response but it doesn't return a JWT.
Copy code
if (session) {
  const response = await newOrySdk(project).toSession({
    xSessionToken: session.session_token,
    tokenize_as: "jwt_template1",
  });
  console.log(response);
  const jwt = response.tokenized;
  console.log(jwt);
}
Do you have any advise?
b
could you post the claims mapper as well?
n
I used the same values that already mention in the example
b
Ah I think, that endpoint only works for Ory session cookies. You already have a token, and can use directly. Would that work? Or is there any specific reason you need a JWT?
n
We want to pass JWT to the services of our backend APIs. In JWT, token validation is easier with IDP's public key. How can the ORY session token be validated in the backend? Do we need to call ORY in every request. Or can I add ORY session as a cookie to this request?
b
I see, yea, to validate a token you’d need to call /sessions/whoami again. And looking at the code it should work. What does the
console.log(response)
print exactly?
n
Here is the response
Did you have a chance to look at my last response? What can you suggest for this topic? @bland-eye-99092
b
The
tokenize_as
parameter should be
tokenizeAs
. The docs are wrong, sorry about that.
n
Oh I see, I will test it again
Thanks @bland-eye-99092 It is working now