[keycloak-user] Accessing Admin Console from client application without logging in

kapil joshi kapilkumarjoshi001 at gmail.com
Tue Jan 29 06:48:00 EST 2019


Hi All,

In our product, we are using keycloak.js adapter. We are receiving access
and refresh token from 3rd party server.  We store these tokens in our
instance variables and update keycloak.js variables explicitly as shown
below:

let tokenStr = this.someService.tokenString;
console.log('token is ' + tokenStr);

let keycloakInstance = this.keycloakAngular.getKeycloakInstance();
if (tokenStr) {
  if (keycloakInstance['tokenTimeoutHandle']) {
    clearTimeout(keycloakInstance['tokenTimeoutHandle']);
    keycloakInstance['tokenTimeoutHandle'] = null;
  }
  keycloakInstance.token = tokenStr;
  keycloakInstance.authenticated = true;
  this.authenticated = true;
  keycloakInstance.tokenParsed = this.decodeToken(tokenStr);
  keycloakInstance.subject = keycloakInstance.tokenParsed.sub;
  keycloakInstance.realmAccess = keycloakInstance.tokenParsed.realm_access;
  keycloakInstance.resourceAccess =
keycloakInstance.tokenParsed.resource_access;
  this.roles = await this.keycloakAngular.getUserRoles(true);


This code is actually taken from setToken() API of keycloak.js and we
have just replaced it in our custom code.

So that we can make use of the keycloak.js adapter variables and methods.


Problem is when we try to access the account-management UI, it takes
the user to login screen, which want to avoid.

we are not able to find out the reason behind this ? When we login to
the application and

then when we try accessing account management url then it renders the
account management page seamlessly.

Would be great if there is a solution to render account management UI
when we update the tokens programatically into keycloak.js adapter
variables.


Let me know If we are doing anything wrong or work arounds to fix this issue.


Thanks

Kapil


More information about the keycloak-user mailing list