title: Why it gets HTTP 401 error with @GET retrofit?
body: <p>When I would like to use <code>@Get</code> I get 401 HTTP error which means I am not authorized.
  Before that I make <code>POST</code> on <code>/authentication</code> and <code>POST</code> on <code>/authorization</code> and it works I am successfully logged in.
  The weird thing for me is I get two tokens, can someone explain why?</p>
  <pre><code>class AuthInterceptor(context: Context) : Interceptor {
      private val sessionManager = SessionManager(context)
  
      override fun intercept(chain: Interceptor.Chain): Response {
          val requestBuilder = chain.request().newBuilder()
  
          // If token has been saved, add it to the request
          sessionManager.fetchAuthToken()?.let {
              requestBuilder.addHeader(&quot;Authorization&quot;, &quot;Bearer $it&quot;)
              Log.d(&quot;authorization&quot;, &quot;$it&quot;)
  // on authorization I get two tokens, after click Login first appears, 2 seconds later next one
          }
  
          return chain.proceed(requestBuilder.build())
      }
  }
  </code></pre>
  <p>Api</p>
  <pre><code>// I think I do not need add here @Headers if I use method in previous class requestBuilder.addHeader~
  
  interface Api {
      @GET(&quot;device&quot;)
      suspend fun getDetails(@Query(&quot;id&quot;) id: String): CameraResponse
  }
  </code></pre>
  <p>authApi</p>
  <pre><code>
  interface AuthApi {
      @POST(&quot;authenticate&quot;)
      fun login(@Body request: User): Call&lt;AuthResponse&gt;
  
      @POST(&quot;authorize&quot;)
      fun authorize(@Body request: AuthResponse): Call&lt;AuthorizeResponse&gt;
  }
  </code></pre>
  <p>error from stacktrace</p>
  <pre><code>W/System.err: retrofit2.HttpException: HTTP 401 
          at retrofit2.KotlinExtensions$await$2$2.onResponse(KotlinExtensions.kt:53)
          at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:161)
          at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
  W/System.err:     at java.lang.Thread.run(Thread.java:923)
  
  </code></pre>
  <p>My documentation</p>
  <pre><code>curl -X GET https://myApiDocumentation/device -d &quot;id=[MY_ID]&quot; -H &quot;Authentication: [API_KEY]&quot; --cookie &quot;auth_key=[AUTH_KEY]&quot; -G
  </code></pre>
  <p>If you need more code from program, here is my post which is fixed and another problem occurs...
  <a href="https://stackoverflow.com/questions/71189706/why-it-gets-http-404-error-with-get-retrofit">Why it gets HTTP 404 error with @GET retrofit?</a></p>