JsonWebTokenHandler.CreateToken Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateToken(String, SigningCredentials, EncryptingCredentials, String, IDictionary<String,Object>, IDictionary<String,Object>)
Creates a JWE (Json Web Encryption).
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
if additionalHeaderClaims
is null.
Applies to
CreateToken(String, SigningCredentials, EncryptingCredentials, String)
Creates a JWE (Json Web Encryption).
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
if compressionAlgorithm
is null.
Applies to
CreateToken(String, SigningCredentials, EncryptingCredentials, IDictionary<String,Object>)
Creates a JWE (Json Web Encryption).
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
if additionalHeaderClaims
is null.
Applies to
CreateToken(String, SigningCredentials, IDictionary<String,Object>)
Creates a JWS (Json Web Signature).
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
if additionalHeaderClaims
is null.
Applies to
CreateToken(String, SigningCredentials, EncryptingCredentials)
Creates a JWE (Json Web Encryption).
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
if encryptingCredentials
is null.
Applies to
CreateToken(String, EncryptingCredentials, String)
Creates a JWE (Json Web Encryption).
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
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.
Applies to
CreateToken(String, SigningCredentials, EncryptingCredentials, String, IDictionary<String,Object>)
Creates a JWE (Json Web Encryption).
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
if additionalHeaderClaims
is null.
Applies to
CreateToken(String, IDictionary<String,Object>)
Creates an unsigned JWS (Json Web Signature).
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
if additionalHeaderClaims
is null.
Applies to
CreateToken(String, SigningCredentials)
Creates a JWS (Json Web Signature).
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
if signingCredentials
is null.
Applies to
CreateToken(String, EncryptingCredentials)
Creates a JWE (Json Web Encryption).
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 JWS (Json Web Signature).
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
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 JWE (Json Web Encryption).
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
if additionalHeaderClaims
is null.
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈