how can I find out the username of the user, that logged in via keycoak in angular
constructor(
appConfig: AppConfigService,
public rest: RestService,
private ip: IpServiceService,
private keycloakService: KeycloakService
) {
...
this.keycloakService
.isLoggedIn()
.then( loggedIn => {
if( loggedIn ) {
console.log(this.keycloakService.getUsername().toString());
} else {
console.log("User not logged in");
}
})
.catch( reason => console.log ( reason ));
I tried the code above, but it doesn't work