Closed natereprogle closed 1 month ago
I know this is an extremely minor change, especially since keycloak-angular automatically attempts to update the token when using the HttpInterceptor or you can just use the keycloakEvents$
Subject. Nonetheless, not everyone will want to immediately refresh the token when it expires, nor will they use Angular's HTTP module (I prefer Axios).
I'm submitting a PR shortly to add an option to refresh the token when getToken()
is called, but it's not mandatory. Let me know if anything needs to change!
Should've closed this when the PR was closed. Per the PR, docs were updated to remove the incorrect info that the token is automatically renewed.
Bug Report or Feature Request (mark with an
x
)Versions.
keycloak-angular: 13.1.0 keycloak-js: 21 angular: 15.2.9
Repro steps.
#getToken()
. The existing, expired token will be retrieved.The log given by the failure.
No logs given, the token is just returned.
I did, however, run a rudimentary test. I called getToken() to get a token, then I used setTimeout to call getToken again 5 minutes later, which is when my token expires. As you can see, the tokens ended up being the same. I then attempted to access a resource that requires a valid token, which returned a 401 unauthorized, proving the token is bad.
Desired functionality.
The token is updated as JSDoc states. I would like to either see the JSDoc updated to not state that the token is refreshed, or have the token actually refresh instead. I know there is a
keycloakEvents$
Subject which has an OnTokenExpired event, so personally I'd like to just see the JSDoc updated to reflect that getToken does not refresh it, but instead gets the last known token.