jwt icon indicating copy to clipboard operation
jwt copied to clipboard

RSA Example in the documentation does not work

Open mdhruv1 opened this issue 3 years ago • 2 comments

var payload = new Dictionary<string, object>
{
    { "claim1", 0 },
    { "claim2", "claim2-value" }
};

IJwtAlgorithm algorithm = new RS256Algorithm(certificate);
IJsonSerializer serializer = new JsonNetSerializer();
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);

var token = encoder.Encode(payload);
Console.WriteLine(token);

The error is Encode is asking for more parameters . Could we amend the code example . The environment is .net 4.0

mdhruv1 avatar Jun 19 '22 17:06 mdhruv1

After alot of trying an example of creating and decoding a JWT token is here. I tested on .net 4.0 and it works

https://gist.github.com/ssippe/8fc11c4d7e766e66f06db0431dba3f0a

The current library not sure what is the issue but does not work on .net 4.0

mdhruv1 avatar Jun 20 '22 00:06 mdhruv1

The example uses a different library, Jose Jwt.

I haven't heard of other reports that it doesn't work on .NET 4.0, I'll give it a try once near my computer.

abatishchev avatar Jun 20 '22 00:06 abatishchev