title: Dagger + Retrofit. Adding auth headers at runtime
body: <p>I'm wondering if there is a way for Dagger to know that it should recreate an object when new data is available.</p>
  
  <p>The instance I am speaking of is with the request headers I have for retrofit. At some point (when the user logs in) I get a token that I need to add to the headers of retrofit to make authenticated requests. The issue is, I'm left with the same unauthenticated version of retrofit. Here's my injection code:</p>
  
  <pre><code>@Provides
      @Singleton
      OkHttpClient provideOkHttpClient(Cache cache) {
          HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
          interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
          OkHttpClient client = new OkHttpClient.Builder()
                  .addInterceptor(interceptor)
                  .cache(cache).build();
           client
                  .newBuilder()
                  .addInterceptor(
                      chain -&gt; {
                          Request original = chain.request();
                          Request.Builder requestBuilder = original.newBuilder()
                                  .addHeader("Accept", "Application/JSON");
                          Request request = requestBuilder.build();
                          return chain.proceed(request);
                      }).build();
          return client;
      }
  
    @Provides
      @Singleton
      Retrofit provideRetrofit(Gson gson, OkHttpClient okHttpClient) { 
          Retrofit retrofit = new Retrofit.Builder()
                  .addConverterFactory(GsonConverterFactory.create(gson))
                  .addCallAdapterFactory(RxErrorHandlingCallAdapterFactory.create())
                  .baseUrl(mBaseUrl)
                  .client(okHttpClient)
                  .build();
          return retrofit;
  }
  
  @Provides
      @Singleton
      public NetworkService providesNetworkService(Retrofit retrofit) {
          return retrofit.create(NetworkService.class);
      }
  </code></pre>
  
  <p>Any ideas on how to make this work?</p>