title: Jwt Unable to valid issuer or audience
body: <p>This is my token decoder. When I try to decode it, my principal ends up being null thus leading to this error: </p>
  
  <blockquote>
    <p>'IDX10208: Unable to validate audience.
    validationParameters.ValidAudience is null or whitespace and
    validationParameters.ValidAudiences is null.'</p>
  </blockquote>
  
  <p>When I decode my token to check</p>
  
  <blockquote>
    <p>"nbf": 1539167980,   "exp": 1539168580,   "iat": 1539167980,   "iss":
    "<a href="http://localhost:55260" rel="noreferrer">http://localhost:55260</a>",   "aud": "<a href="http://localhost:55260" rel="noreferrer">http://localhost:55260</a>"</p>
  </blockquote>
  
  <p>This is the host that my token generator runs on as well. Why is the principal causing issues?</p>
  
  <pre><code>public class DecodeToken
  {
      private IConfiguration configuration;
      public DecodeToken(IConfiguration configuration)
      {
          this.configuration = configuration;
      }
  
      public AuthenticationDto Decode(String Input)
      {
          var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["JwtAuthentication:SecurityKey"]));
          var handler = new JwtSecurityTokenHandler();
          var tokenSecure = handler.ReadToken(Input) as SecurityToken;
          var validations = new TokenValidationParameters
          {
              ValidateIssuerSigningKey = true,
              IssuerSigningKey = key,
              ValidateIssuer = true,
              ValidateAudience = true,
              ValidateLifetime = false
          };
          SecurityToken securityToken;
          var principal = handler.ValidateToken(Input, validations, out securityToken);
          var jwtSecurityToken = securityToken as JwtSecurityToken;
          if (jwtSecurityToken == null || !jwtSecurityToken.Header.Alg.Equals(SecurityAlgorithms.HmacSha256, StringComparison.InvariantCultureIgnoreCase))
          {
              throw new SecurityTokenException("Invalid Token");
          }
          AuthenticationDto authenticationDto = new AuthenticationDto
          {
              Email = principal.Claims.Where(c =&gt; c.Type == "Email").Select(c =&gt; c.Value).SingleOrDefault(),
              UserName = principal.Claims.Where(c =&gt; c.Type == "UserName").Select(c =&gt; c.Value).SingleOrDefault(),
              FirstName = principal.Claims.Where(c =&gt; c.Type == "FirstName").Select(c =&gt; c.Value).SingleOrDefault(),
              LastName = principal.Claims.Where(c =&gt; c.Type == "LastName").Select(c =&gt; c.Value).SingleOrDefault(),
              PhoneNumber = principal.Claims.Where(c =&gt; c.Type == "PhoneNumber").Select(c =&gt; c.Value).SingleOrDefault(),
              Id = principal.Claims.Where(c =&gt; c.Type == "Id").Select(c =&gt; c.Value).SingleOrDefault(),
              ExpiryDateTime = principal.Claims.Where(c =&gt; c.Type == "exp").Select(c =&gt; c.Value).SingleOrDefault(),
              Roles = principal.Claims.Where(c =&gt; c.Type == "Roles").Select(c =&gt; c.Value).ToList(),
          };
          return authenticationDto;
      }
  }
  </code></pre>
  
  <p>This is what my Startup.cs looks like:</p>
  
  <pre><code>services.AddAuthentication(options =&gt; {
      options.DefaultAuthenticateScheme = "Jwt";
      options.DefaultChallengeScheme = "Jwt";
  })
  .AddJwtBearer("Jwt", options =&gt;
  {
      options.TokenValidationParameters = new TokenValidationParameters
      {
          ValidateIssuerSigningKey = true,
          IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["JwtAuthentication:SecurityKey"])),
  
          ValidateIssuer = true,
          ValidIssuer = Configuration["JwtAuthentication:Issuer"],
  
          ValidateAudience = true,
          ValidAudience = Configuration["JwtAuthentication:Audience"],
  
          ValidateLifetime = true, //validate the expiration and not before values in the token
  
          ClockSkew = TimeSpan.Zero //5 minute tolerance for the expiration date
      };
      options.Events = new JwtBearerEvents
      {
          OnAuthenticationFailed = context =&gt;
          {
              if (context.Exception.GetType() == typeof(SecurityTokenExpiredException))
              {
                  context.Response.Headers.Add("Token-Expired", "true");
              }
              return Task.CompletedTask;
          }
      };
  });
  </code></pre>
  
  <p>Have I configured something wrong?</p>