question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HttpInterceptor not working on 2.0.0

See original GitHub issue

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search for issues before submitting

Versions.

@2.0.0 Angular 5.2

Repro steps.

  1. Make Post to keycloak node
  2. Inspect network calls in Chrome
  3. Note missing Authorization header + bearer token
import { BrowserModule } from '@angular/platform-browser';
import {APP_INITIALIZER, NgModule} from '@angular/core';

import { AppComponent } from './app.component';
import { TreasureComponent } from './treasure/treasure.component';
import { LandingComponent } from './landing/landing.component';
import {appRoutes} from './app.routes';
import {HttpClientModule} from '@angular/common/http';
import {KeycloakAngularModule, KeycloakService} from 'keycloak-angular';
import {treasureInit} from './treasure-auth/treasure.authorization.initializer';
import {TreasureAuthorizationGuard} from './treasure-auth/treasure.authorization.guard';

@NgModule({
  declarations: [
    AppComponent,
    TreasureComponent,
    LandingComponent
  ],
  imports: [
    appRoutes,
    BrowserModule,
    HttpClientModule,
    KeycloakAngularModule
  ],
  providers: [
    TreasureAuthorizationGuard,
    {
      provide: APP_INITIALIZER,
      useFactory: treasureInit,
      multi: true,
      deps: [KeycloakService]
    }
  ],  bootstrap: [AppComponent]
})
export class AppModule { }

The AuthGuard works as expected, but the HttpInterceptors do not append the bearer token.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mauriciovigolocommented, May 30, 2018

New versions release, including this update suggested and coded by @Mihai-B! @Mihai-B, thanks for your contribution to this project! @rightisleft thanks for reporting the issues!

1reaction
samherrmanncommented, May 22, 2018

I can confirm the same issue with the following stack: angular: 6.0.0 keycloak: 3.4.3 keycloak-angular: 3.0.0

I agree with @Mihai-B that losing the double negative would be an improvement.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interceptor not intercepting http requests (Angular 6)
Check your module & sub-module files, If you have imported the interceptor in a sub-module, then move it to the root module and...
Read more >
Angular HttpInterceptor not firing on nested Observables-rx.js
Coding example for the question Angular HttpInterceptor not firing on nested ... The problem was fixed after removing the duplicate import.
Read more >
ng-http-interceptor - npm
Description: Gets http RequestOptions from data array. If no options found and alwaysOriginal = false - returns new RequestOptions but does NOT ......
Read more >
Angular: When HttpInterceptor doesn't work with lazy loaded ...
Abou Kone dives into a specific case when using an app wide HttpInterceptor does not work with lazy loaded features.
Read more >
http_interceptor | Dart Package - Pub.dev
codingale.devNull safety• Latest: 1.0.2 / Prerelease: 2.0.0-beta.6 ... Retrying requests when an error occurs or when the response does not match the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found