Error revoking token TypeError: Cannot read property 'toLowerCase' of undefined
See original GitHub issueThis error appears when calling revokeTokenAndLogout()
trying to logout…
Stackblitz example
I implement a login mechanism with angular-oauth2-oidc and Keycloak 9.0.3. Everything seams to work fine except the logout. If i use the simple method logOut()
, I can navigate back to home page without credentials after logout. If i try to use the method revokeTokenAndLogout()
,Ii get this error on console:
Error revoking token TypeError: Cannot read property ‘toLowerCase’ of undefined.
Expected behavior
I am trying to use revokeTokenAndLogout()
instead of logOut()
, because, if I use logOut()
,Ii am redirected to login page but logout is not done because I can go back in the landing page without providing the credentials.
Desktop (please complete the following information):
- OS: Windows 10
- Browser chrome
- Angular 9.1.0
- Keycloak 9.0.3
- “angular-oauth2-oidc”: “^9.2.0”,
Error revoking token TypeError: Cannot read property 'toLowerCase' of undefined
at HttpXsrfInterceptor.intercept (http.js:2790)
at HttpInterceptorHandler.handle (http.js:1941)
at HttpInterceptingHandler.handle (http.js:2873)
at MergeMapSubscriber.project (http.js:1665)
at MergeMapSubscriber._tryNext (mergeMap.js:46)
at MergeMapSubscriber._next (mergeMap.js:36)
at MergeMapSubscriber.next (Subscriber.js:49)
at Observable._subscribe (subscribeToArray.js:3)
at Observable._trySubscribe (Observable.js:42)
at Observable.subscribe (Observable.js:28)
(anonymous) @ angular-oauth2-oidc.js:2374
__tryOrUnsub @ Subscriber.js:183
error @ Subscriber.js:135
_error @ Subscriber.js:75
error @ Subscriber.js:55
notifyError @ OuterSubscriber.js:7
_error @ InnerSubscriber.js:14
error @ Subscriber.js:55
_error @ Subscriber.js:75
error @ Subscriber.js:55
_error @ Subscriber.js:75
error @ Subscriber.js:55
_tryNext @ mergeMap.js:49
_next @ mergeMap.js:36
next @ Subscriber.js:49
(anonymous) @ subscribeToArray.js:3
_trySubscribe @ Observable.js:42
subscribe @ Observable.js:28
call @ mergeMap.js:21
subscribe @ Observable.js:23
call @ filter.js:13
subscribe @ Observable.js:23
call @ map.js:16
subscribe @ Observable.js:23
subscribeToResult @ subscribeToResult.js:9
_complete @ combineLatest.js:52
complete @ Subscriber.js:61
(anonymous) @ subscribeToArray.js:5
_trySubscribe @ Observable.js:42
subscribe @ Observable.js:28
call @ combineLatest.js:26
subscribe @ Observable.js:23
(anonymous) @ angular-oauth2-oidc.js:2369
ZoneAwarePromise @ zone-evergreen.js:872
revokeTokenAndLogout @ angular-oauth2-oidc.js:2348
logout @ header.component.ts:52
HeaderComponent_Template_a_click_20_listener @ header.component.html:30
executeListenerWithErrorHandling @ core.js:21697
wrapListenerIn_markDirtyAndPreventDefault @ core.js:21739
(anonymous) @ platform-browser.js:934
invokeTask @ zone-evergreen.js:400
onInvokeTask @ core.js:41249
invokeTask @ zone-evergreen.js:399
runTask @ zone-evergreen.js:168
invokeTask @ zone-evergreen.js:481
invokeTask @ zone-evergreen.js:1596
globalZoneAwareCallback @ zone-evergreen.js:1622
Show 17 more frames
core.js:5871 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'toLowerCase' of undefined
TypeError: Cannot read property 'toLowerCase' of undefined
at HttpXsrfInterceptor.intercept (http.js:2790)
at HttpInterceptorHandler.handle (http.js:1941)
at HttpInterceptingHandler.handle (http.js:2873)
at MergeMapSubscriber.project (http.js:1665)
at MergeMapSubscriber._tryNext (mergeMap.js:46)
at MergeMapSubscriber._next (mergeMap.js:36)
at MergeMapSubscriber.next (Subscriber.js:49)
at Observable._subscribe (subscribeToArray.js:3)
at Observable._trySubscribe (Observable.js:42)
at Observable.subscribe (Observable.js:28)
at resolvePromise (zone-evergreen.js:793)
at zone-evergreen.js:707
at SafeSubscriber._error (angular-oauth2-oidc.js:2376)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
at SafeSubscriber.error (Subscriber.js:135)
at Subscriber._error (Subscriber.js:75)
at Subscriber.error (Subscriber.js:55)
at CombineLatestSubscriber.notifyError (OuterSubscriber.js:7)
at InnerSubscriber._error (InnerSubscriber.js:14)
at InnerSubscriber.error (Subscriber.js:55)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:9
Top GitHub Comments
in my case, i play with flight sample from this repo (angular-oauth2-oidc/projects/sample)… If i start the app with the original configs an try the login and logout with code flow, it works fine…
But, if i switch the auth-code-flow.config.ts issuer and clientId to my keycloak realm and client:
i’m getting the same error:
In my case, the problem is, that the
revocation_endpoint
is missing in keycloak descovery document (http://localhost:8080/auth/realms/my-realm/.well-known/openid-configuration
)!!! And theOAuthService
needs it to revoke access and refresh tokens in:Keycloak doesn’t support
revocation_endpoint
at the moment, see issue I’m looking for a workaround… any ideas?Update: as workaround i can call
this.oauthService.logOut();
instead ofthis.oauthService.revokeTokenAndLogout();
… and it works with keycloak because it uses.end_session_endpoint
supported by Keycloak! Ok, for me enough good workaround.I hope, my research helps you to fix the error in
revokeTokenAndLogout
… a simple check ifrevokeEndpoint
is defined, may be 😉to solve
TypeError: Cannot read property 'toLowerCase' of undefined
onrevokeTokenAndLogout
,is necessary to add
revocationEndpoint
on auth config