Skip to content

Commit

Permalink
Added missing IBase64UrlEncoder to code samples (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiobernasconi authored and abatishchev committed Apr 12, 2017
1 parent dd35710 commit 872cbf4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var secret = "GQDstcKsx0NHjPOuXOYg5MbeJ1XT0uFiwDVvVBrk";

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

var token = encoder.Encode(payload, secret);
Console.WriteLine(token);
Expand All @@ -41,7 +42,8 @@ try
IJsonSerializer serializer = new JsonNetSerializer();
IDateTimeProvider provider = new UtcDateTimeProvider();
IJwtValidator validator = new JwtValidator(serializer, provider);
IJwtDecoder decoder = new JwtDecoder(serializer, validator);
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder);

var json = decoder.Decode(token, secret, verify: true);
Console.WriteLine(json);
Expand Down Expand Up @@ -115,5 +117,6 @@ And then pass this serializer as a dependency to JwtEncoder constructor:
```csharp
IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
IJsonSerializer serializer = new CustomJsonSerializer();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer);
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);
```

0 comments on commit 872cbf4

Please sign in to comment.