hey Ory team, I would love to get some advice on h...
# ory-network
w
hey Ory team, I would love to get some advice on how we could proceed with Ory in RN + in-app browser. the goal: we have an identity web app that we use to auth users for our web apps. we are also building a RN app, using the same Ory instance. We want to save time and avoid rewriting some flows (in our case, registration and recovery flow) from scratch in RN. I'll describe what I was hoping to achieve and what I've tried and maybe you can point me to the right direction or break my heart by saying it's not possible with Ory 😿 I thought we could use an in-app browser in the app with our custom next.js authentication web app we've built with Ory elements, to register users, and then automatically have users logged in in the app after successful registration without the need for them to log in in the native app. 1. So I've tried registering users in an in-app web page with our next.js app, passing the active token back to RN and using the token from the in-app web session — illegal, 401 when trying to use this token for whoami. 2. I've tried to start a native registration flow in the RN app with
session_token_exchange_code
, passing the flow id to the in-app web page, and this also is not allowed. Is there any legal way to use an in-app web registration page and pass the active session/token to the RN app? There are a bunch of apps that use this approach, and maybe I am missing a step? many thanks in advance! šŸ’›
@magnificent-energy-493 hi, I would greatly appreciate if someone could answer my question above. I kinda understand it's most probably a dead end, but it will help to get your opinion šŸ™
m
Hey @wonderful-salesclerk-46148 apologies, I drafted a response but never sent it to you šŸ¤¦ā€ā™‚ļø The main problem here is the Cookie <-> (native) Token isolation Ory enforces a strict security boundary between session cookies (browser flows) and session tokens (native/API flows). They cannot be exchanged. It's a bit tricky but this might be a workaround that you could use: • open your web app in an in-app browser, complete the browser-based flow (which sets a session cookie), then use
window.postMessage
or a deeplink with a query string to pass data back to the native app. The limitation here is that what you'd be passing back is a session cookie value, not a session token. You could have a trusted backend endpoint that accepts that cookie value, validates it against Ory's /sessions/whoami, and then issues your own app-level token. But Ory itself won't convert the cookie into a native session token. So you would need to build this backend glue layer yourself, the rest is supported by Ory as normal
w
thank you so much! šŸ’› this was very helpful
m
some kind of token generated & validated by the app itself
yes I mean this basically
šŸ‘ 1
e
Ok thanks!