I'm using JwtSecurityTokenHandler
to issue tokens in a aspnet core web api app:
JwtSecurityToken token = BuildJwtSecurityToken(...);
public string toks = new JwtSecurityTokenHandler().WriteToken(token);
each time a token is requested and created, a new JwtSecurityTokenHandler is instantiated, can I use a global instance of it and use it for every token generation?
private JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
private GenToken(JwtSecurityToken token) => handler.WriteToken(token);
Is there any problems to use like this?
Docs say instance members for JwtSecurityTokenHandler
are not guaranteed to be thread safe.
https://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.jwtsecuritytokenhandler(v=vs.114).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With