I am trying to use the Keycloak-js(from 4.4.0.Final) library in my
ionic(4) cordova application.
I have followed the example
<
https://github.com/keycloak/keycloak/tree/master/examples/cordova-native>
and instructions
<
https://www.keycloak.org/docs/latest/securing_apps/index.html#_javascript...
from the documentation.
I have installed cordova-plugin-browsertab, cordova-plugin-deeplinks,
cordova-plugin-inappbrowser.
Added <preference name="AndroidLaunchMode" value="singleTask" />
in my
config.xml
And
<widget id="org.phidatalab.radar_armt"....>
<plugin name="cordova-plugin-browsertab" spec="0.2.0" />
<plugin name="cordova-plugin-inappbrowser" spec="3.0.0" />
<plugin name="cordova-plugin-deeplinks" spec="1.1.0" />
<preference name="AndroidLaunchMode" value="singleTask" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<universal-links>
<host name="keycloak-cordova-example.mydomain.net"
scheme="https">
<path event="keycloak" url="/login" />
</host>
</universal-links>
</widget>
and my service which uses Keycloak-js looks like below.
static init(): Promise<any> {
// Create a new Keycloak Client Instance
let keycloakAuth: any = new Keycloak({
url: 'https://mydomain.net/auth/',
realm: 'mighealth',
clientId: 'armt',
});
return new Promise((resolve, reject) => {
keycloakAuth.init({
onLoad: 'login-required',
adapter: 'cordova',
responseMode: 'query',
redirectUri:
'android-app://org.phidatalab.radar_armt/https/keycloak-cordova-example.github.io/login'
}).success(() => {
console.log("Success")
resolve();
}).error((err) => {
reject(err);
});
});
}
I can successfully build and run the application for android. However, it
doesn't work.
If I try to run it on browser, I get "universalLink is undefined".
I would really like some help to get this working. What am I missing? Any
kind of help is much appreciated.
Best, Nivethika
--
Nivethika Mahasivam | Software Engineer (Real World Data Team)
<
http://www.thehyve.nl>
E. nivethika(a)thehyve.nl
T. +31(0)65 041 619 1
<
https://twitter.com/nivemaham>Twitter <
https://twitter.com/nivemaham>. |
LinkedIn <
https://www.linkedin.com/in/nivemaham/>.