title: Injector Error "Provider parse errors: Cannot instantiate cyclic dependency!"
body: <p>I tried to create an <strong>HttpInterceptor</strong> to add some headers for authorization to every http that happens. I need to get the headers from a service called <strong>AuthService</strong>. Here is the code below:</p>
  
  <p>Interceptor:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
  import { AuthService } from './auth.service';
  
  @Injectable()
  export class AuthInterceptor implements HttpInterceptor {
    constructor(private auth: AuthService) { }
  }
  </code></pre>
  
  <p>AuthService:</p>
  
  <pre><code>import { HttpClient } from '@angular/common/http';
  import { Injectable } from '@angular/core';
  
  @Injectable()
  export class AuthService {
    constructor(private http: HttpClient) { }
  }
  </code></pre>
  
  <p>AppModule:</p>
  
  <pre><code>providers: [{
      provide: HTTP_INTERCEPTORS,
      useClass: AuthInterceptor,
      multi: true,
    }, AuthService]
  </code></pre>
  
  <p>I receive the following error: </p>
  
  <blockquote>
    <p>Error: Provider parse errors:
        Cannot instantiate cyclic dependency! InjectionToken_HTTP_INTERCEPTORS ("[ERROR ->]"): in NgModule AppModule
    in ./AppModule@-1:-1</p>
  </blockquote>
  
  <p>I already checked the previous answers but I don't understand where the cyclic dependency was detected. What I am trying to do is described here: <a href="https://angular.io/guide/http#setting-new-headers" rel="nofollow noreferrer">https://angular.io/guide/http#setting-new-headers</a></p>