Keycloak-angular: KeycloakService.addTokenToHeader 7.3.0 regression

Created on 6 Jun 2020  路  5Comments  路  Source: mauriciovigolo/keycloak-angular

Bug Report or Feature Request (mark with an x)

- [ X] bug report
- [ ] feature request

Versions.

keycloak-angular 7.3.0
angualr 9.1.1
keycloak-js 9.0.2

Repro steps.

It seems there is a regression from version 7.2.0 to 7.3.0.
The reproduction is straightforward, do a GET request using angular HttpClient expecting the bearer token to be added automatically.

The injection (and subsequently the request) fails.

The log given by the failure.

ERROR TypeError: You provided '() => Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"])(this, void 0, void 0, function* () {
            const token = yield this.getToken();
            return headers.set(this._authorizationHeaderName, this._bearerPrefix + token);
        })' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
    at subscribeTo (subscribeTo.js:27)
    at from (from.js:9)
    at KeycloakService.addTokenToHeader (keycloak-angular.js:244)
    at KeycloakBearerInterceptor.handleRequestWithTokenHeader (keycloak-angular.js:289)
    at MergeMapSubscriber.project (keycloak-angular.js:285)
    at MergeMapSubscriber._tryNext (mergeMap.js:46)
    at MergeMapSubscriber._next (mergeMap.js:36)
    at MergeMapSubscriber.next (Subscriber.js:49)
    at subscribeToPromise.js:5
    at ZoneDelegate.invoke (zone-evergreen.js:364)
Bug

Most helpful comment

Hi @ermannob, thank you for reporting the issue.
Version 7.3.1 is now released and includes the fix for this issue.

All 5 comments

I got the same bug

Can confirm this..
Breaks all requests.

Hi @ermannob, thank you for reporting the issue.
Version 7.3.1 is now released and includes the fix for this issue.

Sorry for breaking this guys, looks like I missed this method during my testing. @mauriciovigolo I'll try to add some more tests as I refactor the code.

Hi @jonkoops, no problem :+1:. Thank you.

Was this page helpful?
0 / 5 - 0 ratings