Good to see the flow, but that uses session tokens...
# ory-selfhosting
c
Good to see the flow, but that uses session tokens and I want to use JWT instead as the API and other elements of the platform are built around that (they get the JWT from the authorisation header, decode and validate it and then grab some of the properties out of it like the users email
m
You can use session tokens for the mobile app and JWT for the API - what is the problem with that approach?
c
How would I get the JWT for the mobile app to include in the API calls to our backend?
m
Maybe I am missing something but can you include the JWT in the Authorization header of your API requests to your backend?
c
Yup. My question is how do I get the JWT in the first place?
e.g. with Keycloak I can post the user name and pasword to https://mydockerserver`/realms/myrealm/protocol/openid-connect/token` and it will respond with HTTP 200 and the access token and refresh token, amongst other things
m
I guess it depends if you want to use OAuth2 or not. I would generally not recommend using OAuth2 for first-party user authN - especially with mobile bc then you always have some kind of browser involved. If you use Ory Kratos only without OAuth2 you should be able to use this feature: https://www.ory.sh/docs/identities/session-to-jwt-cors
Alternative would be to use something like Oathkeeper so you dont need to implement this JWT creation in your app, but Oathkeeper handles it: https://www.ory.sh/docs/oathkeeper/pipeline/mutator#id_token
c
That acts a a proxy and when requests pass through it it gets the session from the cookie, looks it up and inserts a JWT into the request before forwarding it on?
m
yes 👍
it basically transforms the authentication information into a JWT / OIDC token
c
the former thing, requesting a token from the server, would be easier for development. if I'm running a local copy of the API server then I couldn't run oathkeeper
thanks for the help
m
sure, feel free to let me know how it goes.