DNX Core 5.0 JwtSecurityTokenHandler"IDX10640:不支持算法:'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256'"

sbo*_*ema 5 c# json jwt adal

我正在尝试实现JWT令牌,但仍然遇到以下异常:IDX10640:不支持算法:' http : //www.w3.org/2001/04/xmldsig-more#hmac-sha256 '尝试写入时用于压缩json字符串的标记.

const string issuer = "issuer";
const string audience = "audience";
byte[] keyForHmacSha256 = new byte[32];
new Random().NextBytes(keyForHmacSha256);

var claims = new List<Claim> { new Claim("deviceId", "12") };
var now = DateTime.UtcNow;
var expires = now.AddHours(1);
var signingCredentials = new SigningCredentials(
    new SymmetricSecurityKey(keyForHmacSha256), 
    SecurityAlgorithms.HmacSha256Signature, SecurityAlgorithms.Sha256Digest);

var token = new JwtSecurityToken(issuer, audience, claims, now, expires, signingCredentials);
return _tokenHandler.WriteToken(token);
Run Code Online (Sandbox Code Playgroud)

解决这个问题的任何想法?

更新1:

"System.IdentityModel.Tokens.Jwt"出现上述错误:"5.0.0-beta7-208241120"

更新2:

更新的代码

Bre*_*ltz 2

我们目前不支持对称密钥。希望尽快得到它。