Keycloak-angular: KeycloakService.addTokenToHeader needs to complete the observable

Created on 17 Jan 2018  Â·  8Comments  Â·  Source: mauriciovigolo/keycloak-angular

The keycloak service creates an observable when calling KeycloakService.addTokenToHeader, but does not call observer.complete() to message the subscribers that it's finished.

This changes the behavior of the angular httpClient methods (get, post, etc.)

As a workaround, we currently have to add a .take(1) (e.g. httpClient.get('protected/url')) to every http operation that is protected by keycloak. URLs that aren't protected work as expected.

I would propose a fix by adding observer.complete(); after this line.
https://github.com/mauriciovigolo/keycloak-angular/blob/266b7d9e104eabb57c45f17c461bd3109ea7c459/src/services/keycloak.service.ts#L328

Bug

Most helpful comment

Hello everyone!

Just released version v.1.2.3 with the bug fix. Thank you so much for opening the issue and for all your help @duydao, also @Herbis for confirming that the issue #5 was also related to this problem.

All 8 comments

Hi @duydao , how are you?

Thank you for reporting the problem. Sorry for the delay to answer you, I'm vacation right now and sometimes I'm totally offline :smile:.

I will take a look at the problem and release a new version.

Thanks for your contribution!!

No worries, thanks alot for taking the time. But for now, enjoy your vacation!

Can confirm, adding the line

observer.complete();

as instructed by @duydao solves #5 as well.

Excellent @Herbis!! Let's release a new version today with the fix for this problem. Thank you!!!

Hi, any chance the new version will be out soon? Otherwise I need to make other arrangements.

I'm really sorry @fennekit and everybody with the same issue. I will try to release today or in this weekend for sure. Was out this week on vacation and it was really hard to work on the library issues. On Monday the new version will be available. Thank you

Hello everyone!

Just released version v.1.2.3 with the bug fix. Thank you so much for opening the issue and for all your help @duydao, also @Herbis for confirming that the issue #5 was also related to this problem.

Works like a charm!

Thanks

On Sun, Jan 28, 2018 at 10:01 AM, Mauricio Gemelli Vigolo <
[email protected]> wrote:

Closed #8 https://github.com/mauriciovigolo/keycloak-angular/issues/8.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mauriciovigolo/keycloak-angular/issues/8#event-1445117734,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADIaoMg4sJVWO_f2b0Zu3XiK_uSBqlh3ks5tPDd9gaJpZM4RhVlT
.

--
Met vriendelijke groet/Kind Regards,

Erik Konijnenburg
http://www.fennek-it.nl
+31 6 24218265

[image: View Erik Konijnenburg's profile on LinkedIn]
http://nl.linkedin.com/pub/erik-konijnenburg/47/106/284

Op onze aanbiedingen zijn de Algemene Voorwaarden
http://www.fennek-it.nl/Algemene%20Voorwaarden.pdf van toepassing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nfriend picture nfriend  Â·  4Comments

Codinger386 picture Codinger386  Â·  4Comments

arratejasvi picture arratejasvi  Â·  4Comments

livthomas picture livthomas  Â·  4Comments

osafi picture osafi  Â·  5Comments