IDX10603: The algorithm: ‘HS256’ requires the SecurityKey.KeySize to be greater than ‘128’ bits. KeySize reported: ’32’. Parameter name: key.KeySize

Ah, it was my mistake, a simple one. I was not providing enough characters for the secret key name.

I changed my signinkey to this one,

var signinKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("this is my custom Secret key for authentication"));

from,

var signinKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("Secret phase"));

That solved my issue, as the HmacSha256 in the line SigningCredentials(signinKey, SecurityAlgorithms.HmacSha256)should be greater than 128 bits. In short, just use a long string as the key.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)