title: How to send Token in Header to server in Android
body: <p>In my application I want to create a <strong>Login</strong>/<strong>Register</strong> page.</p>
  
  <p>In the login page I send the <strong>Username</strong>, <strong>Password</strong>, <strong>Token</strong> from client to Server.</p>
  
  <p>I should get <strong>Username</strong> and <strong>Password</strong> from <strong>USER</strong>, and get <strong>Token</strong> from <code>HEADER</code> of Request.</p>
  
  <p>For connect client to server I use <code>Retorfit 2.2.0</code> library.</p>
  
  <p><strong>Code from the Interface class :</strong> </p>
  
  <pre><code>@POST("User/Authenticate")
  Call&lt;LoginResponse&gt; getLoginResponse(@Header("Token") String token, @Body LoginDatum loginDatum);
  </code></pre>
  
  <p><strong>Code within the Activity :</strong> </p>
  
  <pre><code>public void getLogin(String username, String password) {
  
      final LoginDatum loginDatum = new LoginDatum();
      loginDatum.setUsername(username);
      loginDatum.setPassword(password);
  
      InterfaceApi api = ApiClient.getClient().create(InterfaceApi.class);
      Call&lt;LoginResponse&gt; call = api.getLoginResponse(sendToken, loginDatum);
  
      Log.e("tokenTAG", "Token : " + sendToken);
  
      call.enqueue(new Callback&lt;LoginResponse&gt;() {
          @Override
          public void onResponse(Call&lt;LoginResponse&gt; call, Response&lt;LoginResponse&gt; response) {
              LoginResponse loginResponse = response.body();
              String token = response.headers().get("Token");
              if (token != null) {
                  sendToken = token;
                  Log.e("tokenTAG", "Token : " + sendToken);
              }
              if (loginResponse.getStatusCode() == 200) {
                  Toasty.success(context, context.getResources().getString(R.string.welcome) + " " +
                          loginResponse.getData().getName(), Toast.LENGTH_LONG, true).show();
              } else {
                  Toasty.error(context, loginResponse.getStatusMessage() + "", Toast.LENGTH_LONG, true).show();
              }
              loadProgress.get(0).setVisibility(View.GONE);
              loginBtn.setVisibility(View.VISIBLE);
              btnShadow.setVisibility(View.VISIBLE);
          }
  
          @Override
          public void onFailure(Call&lt;LoginResponse&gt; call, Throwable t) {
              loadProgress.get(0).setVisibility(View.GONE);
              loginBtn.setVisibility(View.VISIBLE);
              btnShadow.setVisibility(View.VISIBLE);
              Toasty.error(context, context.getResources().getString(R.string.failRequest),
                      Toast.LENGTH_LONG, true).show();
          }
      });
  }
  </code></pre>
  
  <p><strong>And show me this in LogCat :</strong> </p>
  
  <pre><code>tokenTAG: Token : null
  tokenTAG: Token : MKGKFPOVRMU4MRK0STNDO20RA2MPEWT7Y1N2WUM5QLIXJX2TEOM9APGUTYJMD8R42WFVESD8GRXCTCINA2LZKU7JV2I7KA2R4N5W
  </code></pre>
  
  <p>But when I want to send the token with  this code : <code>Call&lt;LoginResponse&gt; call = api.getLoginResponse(sendToken, loginDatum);</code> it shows me <strong>null</strong>.</p>
  
  <p>I have use this line : <code>Call&lt;LoginResponse&gt; call = api.getLoginResponse(sendToken, loginDatum);</code> to generate the request callBack, although this line Token is <strong>not NUll</strong>.</p>
  
  <p>How can I fix it?</p>