Home > Enterprise >  What is the difference between CreateToken and WriteToken
What is the difference between CreateToken and WriteToken

Time:02-21

As mentioned, in .Net core we use

var tokenHandler = new JwtSecurityTokenHandler();
    
var token = tokenHandler.CreateToken(tokenDescriptor);
    
return tokenHandler.WriteToken(token);

Here what is the difference between CreateToken and WriteToken?

CodePudding user response:

CreateToken method create security token based on the specified token descriptor and return securitytoken object class.

WriteToken method returns string, i.e serializes the specified security token to a string.

  • Related