title: Gets unauthorized error when I send correctly token
body: <p>I work with Web API and Angular 8.
  I try to secure my server-side but then I get unauthorized error
  for every token I send. </p>
  
  <p>I tried to look for a solution on the internet but I didn't find anything.</p>
  
  <p>That is my code</p>
  
  <p>C#:</p>
  
  <pre><code>public string GenerateTokenForUser(UsersDTO user)
      {
          var signingKey = "xxxxxxxxxxxxxxxxxxxxxx";
          var now = DateTime.UtcNow;
          var key = new SymmetricSecurityKey(Encoding.Default.GetBytes(signingKey));
          var creds = new SigningCredentials(key, 
          SecurityAlgorithms.HmacSha256);
          var claimsIdentity = new ClaimsIdentity(new List&lt;Claim&gt;()
          {
              new Claim(ClaimTypes.Name, user.id.ToString())
          }, "custom");
          var securityTokenDescriptor = new SecurityTokenDescriptor()
          {
              Issuer = "self",
              Subject = claimsIdentity,
              SigningCredentials = creds,
              Expires = now.AddHours(5)
          };
      var tokenHandler = new JwtSecurityTokenHandler();
      var plainToken = tokenHandler.CreateToken(securityTokenDescriptor);
      var signedAndEncodedToken = tokenHandler.WriteToken(plainToken);
      return signedAndEncodedToken;
  }
  </code></pre>
  
  <p>Web API:</p>
  
  <pre><code>    [Authorize]
      [Route("GetLearnedPagesCount/{userId}")]
      public IHttpActionResult GetLearnedPagesCount(int userId)
      {
        ...
      }
  </code></pre>
  
  <p>Angular:</p>
  
  <pre><code>httpOptions = {
    headers: new HttpHeaders({
      'Authorization': `Bearer `+this.cookieService.get('token')
    })
  };
  
   GetLearnedPages(): Observable&lt;Array&lt;MyPages&gt;&gt; {
      return this.httpClient.get&lt;Array&lt;MyPages&gt;&gt;(this.serverServ.URL + "Controller/GetLearnedPages/" 
      + this.user.id, this.httpOptions);
    }
  </code></pre>
  
  <p>I get a correct token and I get it from the cookies too.</p>
  
  <p>What can be my problem?</p>
  
  <p>Thanks!</p>