This package is not maintained anymore.
You can use manfredsteyer/angular-oauth2-oidc to connect with Keycloak.
Example using angular-oauth2-oidc with Keycloak and Ionic (Capacitor): JohannesBauer97/keycloak-ionic-example
This is an extended version of the existing keycloak.js Adapter. It's the same code, I try to keep it up-to-date. The version of keyloak and this package match. The only difference are 2 more adapters for capacitor. It's possible to provide custom adapters, but the original library implements a lot of private methods, which are not accessible with custom adapters. Therefore, duplicate implementations are required for custom adapters.
There is an open discussion about implementing the capacitor adapter in the original library here: https://groups.google.com/g/keycloak-dev/c/_D62KbWTuvc/m/4-1EJ-68BAAJ
Original (v13.0.0) Implementation:
Official Documentation:
Extensions:
capacitor
adaptercapacitor-native
adapterAdapter to use the system browser.
The adapter will directly access Capacitors app api to listen to iOS (universal links) and Android deep links. Also the native browser will be opened for the login/logout/register and account management pages.
npm i keycloak-ionic
public keycloak: Keycloak.KeycloakInstance;
constructor()
{
this.keycloak = Keycloak({
clientId: 'webapp',
realm: 'master',
url: 'http://localhost:8080/auth/'
});
this.keycloak.init({
adapter: 'capacitor-native',
responseMode: 'query',
redirectUri: 'http://localhost:8100'
});
// Test if it works, when coming back from this.keycloak.login();
this.keycloak.onAuthSuccess = () => {
console.log('authenticated!');
};
}
Adapter to use an inApp browser
The adapter will directly access Capacitors app api to listen to iOS (universal links) and Android deep links. Also the inApp browser will be opened for the login/logout/register and account management pages.
npm i keycloak-ionic
Check out the examples
folder.
public keycloak: Keycloak.KeycloakInstance;
constructor()
{
this.keycloak = Keycloak({
clientId: 'webapp',
realm: 'master',
url: 'http://localhost:8080/auth/'
});
this.keycloak.init({
adapter: 'capacitor',
responseMode: 'query',
redirectUri: 'http://localhost:8100'
});
// Test if it works, when coming back from this.keycloak.login();
this.keycloak.onAuthSuccess = () => {
console.log('authenticated!');
};
}