Class Jwt
A lightweight implementation of Json Web Token (JWT) suitable for use by client applications. The JWT structure is described here.
Namespace: Neon.Net
Assembly: Neon.Common.dll
Syntax
public class Jwt
Properties
Header
Returns a Newtonsoft JObject with the JWT header properties.
Declaration
public JObject Header { get; }
Property Value
Type | Description |
---|---|
JObject |
Payload
Returns a Newtonsoft JObject with the JWT payload properties.
Declaration
public JObject Payload { get; }
Property Value
Type | Description |
---|---|
JObject |
Signature
Returns the JWT signature as a byte array.
Declaration
public byte[] Signature { get; }
Property Value
Type | Description |
---|---|
byte[] |
Methods
Parse(string)
Parses a Jwt from an encoded string.
note
WARNING: This method does not verify the signature so it is not suitable for verifying a JWT's authenticity.
Declaration
public static Jwt Parse(string jwtString)
Parameters
Type | Name | Description |
---|---|---|
string | jwtString | The encoded JWT string. |
Returns
Type | Description |
---|---|
Jwt | The parsed Jwt instance. |
Exceptions
Type | Condition |
---|---|
FormatException | Thrown if the JWT format is invalid. |
ToString()
Renders the JWT back into its encoded string format.
note
This method currently returns the original string used to parse the JWT. It does not actually perform any encoding so any changes made to the properties will not be included in the output.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The encode JWT. |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the JWT wasn't parsed from a string. |