abd
abd

Reputation: 81

What is the difference between CreateToken and WriteToken

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?

Upvotes: 2

Views: 1398

Answers (1)

Satinder singh
Satinder singh

Reputation: 10198

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.

Upvotes: 1

Related Questions