C# Class JWT.JsonWebToken

Provides methods for encoding and decoding JSON Web Tokens.
Show file Open project: NuGet/OpsDashboard

Public Methods

Method Description
Decode ( string token, string key, bool verify = true ) : string

Creates a JWT given a payload, the signing key, and the algorithm to use.

Given a JWT, decode it and return the JSON payload.

DecodeToObject ( string token, string key, bool verify = true ) : object

Given a JWT, decode it and return the payload as an object (by deserializing it with System.Web.Script.Serialization.JavaScriptSerializer).

Private Methods

Method Description
Base64UrlDecode ( string input ) : byte[]
Base64UrlEncode ( byte input ) : string
CreateHMACVerifier ( HMAC>.Func hmacFac ) : Func
GetHashAlgorithm ( string algorithm ) : JwtHashAlgorithm
JsonWebToken ( ) : System
VerifyRSAHash ( string algorithm ) : Func

Method Details

Decode() public static method

Creates a JWT given a payload, the signing key, and the algorithm to use. Given a JWT, decode it and return the JSON payload.
Thrown if the verify parameter was true and the signature was NOT valid or if the JWT was signed with an unsupported algorithm.
public static Decode ( string token, string key, bool verify = true ) : string
token string The JWT.
key string The key used to sign the token.
verify bool Whether to verify the signature (default is true).
return string

DecodeToObject() public static method

Given a JWT, decode it and return the payload as an object (by deserializing it with System.Web.Script.Serialization.JavaScriptSerializer).
Thrown if the verify parameter was true and the signature was NOT valid or if the JWT was signed with an unsupported algorithm.
public static DecodeToObject ( string token, string key, bool verify = true ) : object
token string The JWT.
key string The key that was used to sign the JWT.
verify bool Whether to verify the signature (default is true).
return object