-
Notifications
You must be signed in to change notification settings - Fork 5
Using the KeycloakService
Stan Silvert edited this page Jan 29, 2018
·
3 revisions
keycloak-schematic installs an injectable KeycloakService. This is added to your application in exactly the same manner as any other service created with the Angular CLI.
Just import and add to the constructor of your class.
import { KeycloakService } from './keycloak-service/keycloak.service';
.
.
constructor(private kcSvc: KeycloakService) {}KeycloakService is a wrapper for the Keycloak javascript adapter. The methods available are as follows:
authenticated(): boolean
login(options?: KeycloakLoginOptions) : void
logout(redirectUri?: string) : void
account(): void
authServerUrl(): string
realm(): stringThe KeycloakService does not expose everything you might need for more advanced usage. If you want to use the javascript adapter directly, add this to your code:
import * as Keycloak from './keycloak-service/keycloak';
type KeycloakClient = Keycloak.KeycloakInstance;For details on using the Keycloak javascript adapter, see the 'Securing Apps' document from Keycloak.