title: How to generate JWT Token with IdentityModel Extensions for .NET 5
body: <p>I am using  <a href="https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet" rel="noreferrer">IdentityModel Extensions for .NET</a> version 4 to generate JWT token with <em>symmetric key</em> and <em>SHA256</em> as below and it works perfectly:</p>
  <pre><code>var tokenDescriptor = new SecurityTokenDescriptor
  {
      Subject = new ClaimsIdentity(claims),
  
      TokenIssuerName = Issuer,
      AppliesToAddress = Audience,
  
      Lifetime = new Lifetime(now, expirationTime),
  
      SigningCredentials = new SigningCredentials(
          new InMemorySymmetricSecurityKey(symmetricKey),
          &quot;http://www.w3.org/2001/04/xmldsig-more#hmac-sha256&quot;,
          &quot;http://www.w3.org/2001/04/xmlenc#sha256&quot;),
  };
  
  var securityToken = tokenHandler.CreateToken(tokenDescriptor);
  var token = tokenHandler.WriteToken(securitytoken);
  </code></pre>
  <p>But when I tried to upgrade to IdentityModel Extensions for .NET 5 as below code:</p>
  <pre><code>var tokenDescriptor = new SecurityTokenDescriptor
  {
      Subject = new ClaimsIdentity(claims),
  
      Issuer = Issuer,
      Audience = Audience,
  
      Expires = expirationTime,
      SigningCredentials = new SigningCredentials(
          new SymmetricSecurityKey(symmetricKey), &quot;SHA256&quot;)
  };
  
  var securityToken = tokenHandler.CreateToken(tokenDescriptor);
  var token = tokenHandler.WriteToken(stoken);
  </code></pre>
  <p>I got exception:</p>
  <blockquote>
  <p>IDX10634: Unable to create the SignatureProvider.</p>
  <p>SignatureAlgorithm: 'SHA256', SecurityKey: 'Microsoft.IdentityModel.Tokens.SymmetricSecurityKey'
  is not supported.</p>
  </blockquote>
  <p>What's wrong with the new code using version 5.</p>