Hi all, I’m building a mobile app using Capacitor, I have a web-app hosted at let’s say https://abc.example.com, I want to render the https://abc.example.com in the webView, So for that I have added below code in the Capacitor config
"server": {
"url": "https://abc.example.com",
"cleartext": false
}
And My app is rendering in the webView in mobile apps, But I have a Sign in button in the web-app, I use keycloak to authenticate users(keycloak-js package)
Problem
The keycloak login page is opening in the default browser of the mobile and not in the webView, the user can log in there, but then it’s redirecting to the localhost#state=… and not in the webview
But I read that there are ways to capture the redirect on your custom redirect URLs and then open the app when you capture it, But the issue is that keycloak-js store the challenge verifier code etc in the instance and if it start the new instance then those will be lost and even though I got the state and code from keycloak, I will not be able to fetch the tokens from it
The other way is, I guess, to do the keycloak auth in the capacitor base app itself and send the tokens to the hosted web-app when rendering it(like store in localstorage and web-app will read it), but the issue with that is I have some pages which do not require authentication, so I cant force authentication when the app is loaded, and so the user need to click on Sign in button to start the authentication but I can’t interrupt it because if I modify the code as to not do the regular flow of opening the keycloak login page then the hosted web-app will break.
So what options do I have? How are you guys handling such situations?