JsonWebTokenHandler.CreateToken Method

Definition

Overloads

CreateToken(String, SigningCredentials, EncryptingCredentials, String, IDictionary<String,Object>, IDictionary<String,Object>)

Creates a JSON Web Encryption (JWE).

CreateToken(String, SigningCredentials, EncryptingCredentials, String)

Creates a JSON Web Encryption (JWE).

CreateToken(String, SigningCredentials, EncryptingCredentials, IDictionary<String,Object>)

Creates a JSON Web Encryption (JWE).

CreateToken(String, SigningCredentials, IDictionary<String,Object>)

Creates a JSON Web Signature (JWS).

CreateToken(String, SigningCredentials, EncryptingCredentials)

Creates a JSON Web Encryption (JWE).

CreateToken(String, EncryptingCredentials, String)

Creates a JSON Web Encryption (JWE).

CreateToken(String, SigningCredentials, EncryptingCredentials, String, IDictionary<String,Object>)

Creates a JSON Web Encryption (JWE).

CreateToken(String, IDictionary<String,Object>)

Creates an unsigned JSON Web Signature (JWS).

CreateToken(String, SigningCredentials)

Creates a JSON Web Signature (JWS).

CreateToken(String, EncryptingCredentials)

Creates a JSON Web Encryption (JWE).

CreateToken(String)

Creates an unsigned JSON Web Signature (JWS).

CreateToken(SecurityTokenDescriptor)

Creates a JWT that can be a JWS or JWE.

CreateToken(String, EncryptingCredentials, IDictionary<String,Object>)

Creates a JSON Web Encryption (JWE).

CreateToken(String, SigningCredentials, EncryptingCredentials, String, IDictionary<String,Object>, IDictionary<String,Object>)

Creates a JSON Web Encryption (JWE).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials, string compressionAlgorithm, System.Collections.Generic.IDictionary<string,object> additionalHeaderClaims, System.Collections.Generic.IDictionary<string,object> additionalInnerHeaderClaims);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * string * System.Collections.Generic.IDictionary<string, obj> * System.Collections.Generic.IDictionary<string, obj> -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * string * System.Collections.Generic.IDictionary<string, obj> * System.Collections.Generic.IDictionary<string, obj> -> string
Public Overridable Function CreateToken (payload As String, signingCredentials As SigningCredentials, encryptingCredentials As EncryptingCredentials, compressionAlgorithm As String, additionalHeaderClaims As IDictionary(Of String, Object), additionalInnerHeaderClaims As IDictionary(Of String, Object)) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

signingCredentials
SigningCredentials

Defines the security key and algorithm that will be used to sign the JWT.

encryptingCredentials
EncryptingCredentials

Defines the security key and algorithm that will be used to encrypt the JWT.

compressionAlgorithm
String

Defines the compression algorithm that will be used to compress the JWT token payload.

additionalHeaderClaims
IDictionary<String,Object>

Defines the dictionary containing any custom header claims that need to be added to the outer JWT token header.

additionalInnerHeaderClaims
IDictionary<String,Object>

Defines the dictionary containing any custom header claims that need to be added to the inner JWT token header.

Returns

A JWE in Compact Serialization format.

Exceptions

Thrown if additionalHeaderClaims is null.

Thrown if Alg, KidX5t, Enc, and/or Zip are present inside of additionalHeaderClaims.

Applies to

CreateToken(String, SigningCredentials, EncryptingCredentials, String)

Creates a JSON Web Encryption (JWE).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials, string compressionAlgorithm);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * string -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * string -> string
Public Overridable Function CreateToken (payload As String, signingCredentials As SigningCredentials, encryptingCredentials As EncryptingCredentials, compressionAlgorithm As String) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

signingCredentials
SigningCredentials

Defines the security key and algorithm that will be used to sign the JWT.

encryptingCredentials
EncryptingCredentials

Defines the security key and algorithm that will be used to encrypt the JWT.

compressionAlgorithm
String

Defines the compression algorithm that will be used to compress the JWT token payload.

Returns

A JWE in Compact Serialization format.

Exceptions

Thrown if compressionAlgorithm is null.

Applies to

CreateToken(String, SigningCredentials, EncryptingCredentials, IDictionary<String,Object>)

Creates a JSON Web Encryption (JWE).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials, System.Collections.Generic.IDictionary<string,object> additionalHeaderClaims);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * System.Collections.Generic.IDictionary<string, obj> -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * System.Collections.Generic.IDictionary<string, obj> -> string
Public Overridable Function CreateToken (payload As String, signingCredentials As SigningCredentials, encryptingCredentials As EncryptingCredentials, additionalHeaderClaims As IDictionary(Of String, Object)) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

signingCredentials
SigningCredentials

Defines the security key and algorithm that will be used to sign the JWT.

encryptingCredentials
EncryptingCredentials

Defines the security key and algorithm that will be used to encrypt the JWT.

additionalHeaderClaims
IDictionary<String,Object>

Defines the dictionary containing any custom header claims that need to be added to the outer JWT token header.

Returns

A JWE in Compact Serialization format.

Exceptions

Thrown if additionalHeaderClaims is null.

Thrown if Alg, KidX5t, Enc, and/or Zip are present inside of additionalHeaderClaims.

Applies to

CreateToken(String, SigningCredentials, IDictionary<String,Object>)

Creates a JSON Web Signature (JWS).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials, System.Collections.Generic.IDictionary<string,object> additionalHeaderClaims);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * System.Collections.Generic.IDictionary<string, obj> -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * System.Collections.Generic.IDictionary<string, obj> -> string
Public Overridable Function CreateToken (payload As String, signingCredentials As SigningCredentials, additionalHeaderClaims As IDictionary(Of String, Object)) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

signingCredentials
SigningCredentials

Defines the security key and algorithm that will be used to sign the JWS.

additionalHeaderClaims
IDictionary<String,Object>

Defines the dictionary containing any custom header claims that need to be added to the JWT token header.

Returns

A JWS in Compact Serialization format.

Exceptions

Thrown if additionalHeaderClaims is null.

Thrown if Alg, KidX5t, Enc, and/or Zip are present inside of additionalHeaderClaims.

Applies to

CreateToken(String, SigningCredentials, EncryptingCredentials)

Creates a JSON Web Encryption (JWE).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials -> string
Public Overridable Function CreateToken (payload As String, signingCredentials As SigningCredentials, encryptingCredentials As EncryptingCredentials) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

signingCredentials
SigningCredentials

Defines the security key and algorithm that will be used to sign the JWT.

encryptingCredentials
EncryptingCredentials

Defines the security key and algorithm that will be used to encrypt the JWT.

Returns

A JWE in Compact Serialization format.

Exceptions

Thrown if encryptingCredentials is null.

Applies to

CreateToken(String, EncryptingCredentials, String)

Creates a JSON Web Encryption (JWE).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials, string compressionAlgorithm);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.EncryptingCredentials * string -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.EncryptingCredentials * string -> string
Public Overridable Function CreateToken (payload As String, encryptingCredentials As EncryptingCredentials, compressionAlgorithm As String) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

encryptingCredentials
EncryptingCredentials

The security key and algorithm that will be used to encrypt the JWT.

compressionAlgorithm
String

The compression algorithm that will be used to compress the JWT token payload.

Returns

A JWE in Compact Serialization format.

Exceptions

Thrown if compressionAlgorithm is null or empty.

Applies to

CreateToken(String, SigningCredentials, EncryptingCredentials, String, IDictionary<String,Object>)

Creates a JSON Web Encryption (JWE).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials, string compressionAlgorithm, System.Collections.Generic.IDictionary<string,object> additionalHeaderClaims);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * string * System.Collections.Generic.IDictionary<string, obj> -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials * Microsoft.IdentityModel.Tokens.EncryptingCredentials * string * System.Collections.Generic.IDictionary<string, obj> -> string
Public Overridable Function CreateToken (payload As String, signingCredentials As SigningCredentials, encryptingCredentials As EncryptingCredentials, compressionAlgorithm As String, additionalHeaderClaims As IDictionary(Of String, Object)) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

signingCredentials
SigningCredentials

Defines the security key and algorithm that will be used to sign the JWT.

encryptingCredentials
EncryptingCredentials

Defines the security key and algorithm that will be used to encrypt the JWT.

compressionAlgorithm
String

Defines the compression algorithm that will be used to compress the JWT token payload.

additionalHeaderClaims
IDictionary<String,Object>

Defines the dictionary containing any custom header claims that need to be added to the outer JWT token header.

Returns

A JWE in Compact Serialization format.

Exceptions

Thrown if additionalHeaderClaims is null.

Thrown if Alg, KidX5t, Enc, and/or Zip are present inside of additionalHeaderClaims.

Applies to

CreateToken(String, IDictionary<String,Object>)

Creates an unsigned JSON Web Signature (JWS).

public virtual string CreateToken (string payload, System.Collections.Generic.IDictionary<string,object> additionalHeaderClaims);
abstract member CreateToken : string * System.Collections.Generic.IDictionary<string, obj> -> string
override this.CreateToken : string * System.Collections.Generic.IDictionary<string, obj> -> string
Public Overridable Function CreateToken (payload As String, additionalHeaderClaims As IDictionary(Of String, Object)) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

additionalHeaderClaims
IDictionary<String,Object>

Defines the dictionary containing any custom header claims that need to be added to the JWT token header.

Returns

A JWS in Compact Serialization format.

Exceptions

Thrown if additionalHeaderClaims is null.

Applies to

CreateToken(String, SigningCredentials)

Creates a JSON Web Signature (JWS).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.SigningCredentials signingCredentials);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.SigningCredentials -> string
Public Overridable Function CreateToken (payload As String, signingCredentials As SigningCredentials) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

signingCredentials
SigningCredentials

Defines the security key and algorithm that will be used to sign the JWS.

Returns

A JWS in Compact Serialization format.

Exceptions

Thrown if signingCredentials is null.

Applies to

CreateToken(String, EncryptingCredentials)

Creates a JSON Web Encryption (JWE).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.EncryptingCredentials -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.EncryptingCredentials -> string
Public Overridable Function CreateToken (payload As String, encryptingCredentials As EncryptingCredentials) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

encryptingCredentials
EncryptingCredentials

Defines the security key and algorithm that will be used to encrypt the JWT.

Returns

A JWE in Compact Serialization format.

Applies to

CreateToken(String)

Creates an unsigned JSON Web Signature (JWS).

public virtual string CreateToken (string payload);
abstract member CreateToken : string -> string
override this.CreateToken : string -> string
Public Overridable Function CreateToken (payload As String) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

Returns

A JWS in Compact Serialization format.

Exceptions

Thrown if payload is null.

Applies to

CreateToken(SecurityTokenDescriptor)

Creates a JWT that can be a JWS or JWE.

public virtual string CreateToken (Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor tokenDescriptor);
abstract member CreateToken : Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor -> string
override this.CreateToken : Microsoft.IdentityModel.Tokens.SecurityTokenDescriptor -> string
Public Overridable Function CreateToken (tokenDescriptor As SecurityTokenDescriptor) As String

Parameters

tokenDescriptor
SecurityTokenDescriptor

A SecurityTokenDescriptor that contains details of contents of the token.

Returns

A JWT in Compact Serialization format.

Applies to

CreateToken(String, EncryptingCredentials, IDictionary<String,Object>)

Creates a JSON Web Encryption (JWE).

public virtual string CreateToken (string payload, Microsoft.IdentityModel.Tokens.EncryptingCredentials encryptingCredentials, System.Collections.Generic.IDictionary<string,object> additionalHeaderClaims);
abstract member CreateToken : string * Microsoft.IdentityModel.Tokens.EncryptingCredentials * System.Collections.Generic.IDictionary<string, obj> -> string
override this.CreateToken : string * Microsoft.IdentityModel.Tokens.EncryptingCredentials * System.Collections.Generic.IDictionary<string, obj> -> string
Public Overridable Function CreateToken (payload As String, encryptingCredentials As EncryptingCredentials, additionalHeaderClaims As IDictionary(Of String, Object)) As String

Parameters

payload
String

A string containing JSON which represents the JWT token payload.

encryptingCredentials
EncryptingCredentials

Defines the security key and algorithm that will be used to encrypt the JWT.

additionalHeaderClaims
IDictionary<String,Object>

Defines the dictionary containing any custom header claims that need to be added to the outer JWT token header.

Returns

A JWS in Compact Serialization format.

Exceptions

Thrown if additionalHeaderClaims is null.

Thrown if Alg, KidX5t, Enc, and/or Zip are present inside of additionalHeaderClaims.

Applies to