mauriciovigolo / keycloak-angular

Easy Keycloak setup for Angular applications.
MIT License
730 stars 280 forks source link

Token Expired. No Login Redirect #502

Open marct83 opened 1 year ago

marct83 commented 1 year ago

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search for issues before submitting
- [ ] feature request

Versions.

Angular 14.2.0 keycloak-angular 14.0.0 keycloak-js 21.0.0

Repro steps.

When the app loads it retrieves the users token from https://keycloak/auth/realms/toolbox/protocol/openid-connect/token

The response looks like this (I removed the tokens): { "expires_in": -9715, "refresh_expires_in": -9715, "token_type": "Bearer", "not-before-policy": 0, "session_state": "771f9358-e488-4f7d-87ee-bb96164d6f6d", "scope": "openid email profile" }

The app then tries to retrieve the account from https://keycloak/auth/realms/toolbox/account and fails as the token is expired.

error: "HTTP 401 Unauthorized"

The app then just displays a white screen.

The log given by the failure.

main.js:1 [ngDoBootstrap] init Keycloak failed undefined

Desired functionality.

When the token is expired the login screen appears.