Closed Lukc closed 4 years ago
I've added an explicit error for this case as JWT tokens should be JSON hashes. As per the example in the readme:
require "jwt"
payload = { "foo" => "bar" }
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)
However I understand that it might be desirable to encode basically anything like a JWT token so you can avoid the cast now, in version 1.4, by skipping validation:
require "jwt"
token = JWT.encode "token body", "hello, there", JWT::Algorithm::HS256
pp! JWT.decode token, "hello, there", JWT::Algorithm::HS256, validate: false
notice the , validate: false
I've added to your code example.
Hope this helps.
Hello,
I used to use the jwt shard for some time and it always worked fine, until a few days ago. Not sure if started doing something wrong or if something got broken?
Test code
Result
Environment
I did test with Crystal 0.31.1 first and had the same issue.