JwtSecurityTokenHandler.CreateToken Method (String, String, ClaimsIdentity, Lifetime, SigningCredentials, SignatureProvider)

Uses the JwtSecurityToken constructor, first creating the JwtHeader and JwtPayload.If SigningCredentials is not null, RawData will be signed.

Namespace:  System.IdentityModel.Tokens
Assembly:  System.IdentityModel.Tokens.Jwt (in System.IdentityModel.Tokens.Jwt.dll)


Public Overridable Function CreateToken ( _
    issuer As String, _
    audience As String, _
    subject As ClaimsIdentity, _
    lifetime As Lifetime, _
    signingCredentials As SigningCredentials, _
    signatureProvider As SignatureProvider _
) As JwtSecurityToken
public virtual JwtSecurityToken CreateToken(
    string issuer,
    string audience,
    ClaimsIdentity subject,
    Lifetime lifetime,
    SigningCredentials signingCredentials,
    SignatureProvider signatureProvider
virtual JwtSecurityToken^ CreateToken(
    String^ issuer, 
    String^ audience, 
    ClaimsIdentity^ subject, 
    Lifetime^ lifetime, 
    SigningCredentials^ signingCredentials, 
    SignatureProvider^ signatureProvider
abstract CreateToken : 
        issuer:string * 
        audience:string * 
        subject:ClaimsIdentity * 
        lifetime:Lifetime * 
        signingCredentials:SigningCredentials * 
        signatureProvider:SignatureProvider -> JwtSecurityToken  
override CreateToken : 
        issuer:string * 
        audience:string * 
        subject:ClaimsIdentity * 
        lifetime:Lifetime * 
        signingCredentials:SigningCredentials * 
        signatureProvider:SignatureProvider -> JwtSecurityToken
public function CreateToken(
    issuer : String, 
    audience : String, 
    subject : ClaimsIdentity, 
    lifetime : Lifetime, 
    signingCredentials : SigningCredentials, 
    signatureProvider : SignatureProvider
) : JwtSecurityToken


  • audience
    Type: System.String

    the expected audience for this token

Return Value

Type: System.IdentityModel.Tokens.JwtSecurityToken
A JwtSecurityToken.


If Actor is not null, then a claim { actort, 'value' } will be added to the payload. CreateActorValue for details on how the value is created.See for details on how the HeaderParameters are added to the header.

See for details on how the values are added to the payload.

.NET Framework Security

See Also


JwtSecurityTokenHandler Class

CreateToken Overload

System.IdentityModel.Tokens Namespace