[Solved] Can not Implicitly Convert SymmetrySecurityKey Type [closed]


The error is essentially “Cannot convert from SymmetricSecurityKey(string) to IEnumerable<SymmetricSecurityKey>”. This means that the IssuerSigningKeys is expecting an IEnumerable (List or Array) of SymmetricSecurityKey instead of a single value.

The fix is easy, give it an array:

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
                {
                    options.TokenValidationParameters = new TokenValidationParameters
                    {
                        ValidateIssuerSigningKey = true,
                        IssuerSigningKeys = new[] { new SymmetricSecurityKey(key) },
                        ValidateIssuer = false,
                        ValidateAudience = false
                    };
                });

solved Can not Implicitly Convert SymmetrySecurityKey Type [closed]