147 Posts

How to convert result of jwt to json from function GenerateTokens ?
2 minutes ago|LINK|

I have function return string as Encoded access token

 public string GenerateTokens(string userId)
            var Claims = new Claim[]
            new Claim(JwtRegisteredClaimNames.Sub,userId)
            var signingkey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("Engaz@2012"));
            var SigningCredntials = new SigningCredentials(signingkey, SecurityAlgorithms.HmacSha256);
            var Jwt = new JwtSecurityToken();
            var jsonu = new { id = userId };
            Jwt.Payload["user"] = jsonu;
            return new JwtSecurityTokenHandler().WriteToken(Jwt);
public class Users
        public dynamic AccessToken{ get; set; }
when success login


How to return Jwt as jsonresult before encoding from function GenerateTokens();
and put result in user.AccessToken as json
meaning i need to assign jwt variables before converted by JwtSecurityTokenHandler().WriteToken as json and assign it to